Add metrics recording to ProtoLevelDBWrapper.

Adds metrics collection at the LevelDB wrapper level for ProtoDatabase,
so any current clients of ProtoDatabase will have new metrics recorded
for successes/failures and the error status of various LevelDB
operations.

To allow gathering metrics on the LevelDB status for failures,
the parameters to many of the functions have been modified so we can
get the leveldb::Status back in addition to the boolean return value.

Bug: 870813
Change-Id: I5d8175dbd4e3b3531532d2f3fc0b33ca155f1336
Reviewed-on: https://chromium-review.googlesource.com/c/1288904
Reviewed-by: Jesse Doherty <[email protected]>
Reviewed-by: Tommy Nyquist <[email protected]>
Commit-Queue: Troy Hildebrandt <[email protected]>
Cr-Commit-Position: refs/heads/master@{#605725}
diff --git a/components/leveldb_proto/proto_leveldb_wrapper_metrics.h b/components/leveldb_proto/proto_leveldb_wrapper_metrics.h
new file mode 100644
index 0000000..d05bb29
--- /dev/null
+++ b/components/leveldb_proto/proto_leveldb_wrapper_metrics.h
@@ -0,0 +1,40 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_LEVELDB_PROTO_PROTO_LEVELDB_WRAPPER_METRICS_H_
+#define COMPONENTS_LEVELDB_PROTO_PROTO_LEVELDB_WRAPPER_METRICS_H_
+
+#include <string>
+
+namespace leveldb {
+class Status;
+}  // namespace leveldb
+
+namespace leveldb_proto {
+
+// Static metrics recording helper functions for ProtoLevelDBWrapper.
+//
+// When adding database clients that require UMA metrics recording, ensure that
+// the client name is added as a suffix in histograms.xml for the appropriate
+// ProtoDB.* metrics.
+class ProtoLevelDBWrapperMetrics {
+ public:
+  static void RecordInit(const std::string& client,
+                         const leveldb::Status& status);
+  static void RecordUpdate(const std::string& client,
+                           bool success,
+                           const leveldb::Status& status);
+  static void RecordGet(const std::string& client,
+                        bool success,
+                        bool found,
+                        const leveldb::Status& status);
+  static void RecordLoadKeys(const std::string& client, bool success);
+  static void RecordLoadEntries(const std::string& client, bool success);
+  static void RecordLoadKeysAndEntries(const std::string& client, bool success);
+  static void RecordDestroy(const std::string& client, bool success);
+};
+
+}  // namespace leveldb_proto
+
+#endif  // COMPONENTS_LEVELDB_PROTO_PROTO_LEVELDB_WRAPPER_METRICS_H_
\ No newline at end of file