Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(852)

Side by Side Diff: components/leveldb/public/cpp/util.cc

Issue 2886933003: Use stricter type checking in UMA_HISTOGRAM_ENUMERATION (Closed)
Patch Set: simplify type checking Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/leveldb/public/cpp/util.h ('k') | components/metrics/stability_metrics_helper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/leveldb/public/cpp/util.h" 5 #include "components/leveldb/public/cpp/util.h"
6 6
7 #include "third_party/leveldatabase/env_chromium.h" 7 #include "third_party/leveldatabase/env_chromium.h"
8 #include "third_party/leveldatabase/src/include/leveldb/status.h" 8 #include "third_party/leveldatabase/src/include/leveldb/status.h"
9 9
10 namespace leveldb { 10 namespace leveldb {
(...skipping 28 matching lines...) Expand all
39 return leveldb::Status::InvalidArgument(msg, msg2); 39 return leveldb::Status::InvalidArgument(msg, msg2);
40 case mojom::DatabaseError::IO_ERROR: 40 case mojom::DatabaseError::IO_ERROR:
41 return leveldb::Status::IOError(msg, msg2); 41 return leveldb::Status::IOError(msg, msg2);
42 } 42 }
43 43
44 // This will never be reached, but we still have configurations which don't 44 // This will never be reached, but we still have configurations which don't
45 // do switch enum checking. 45 // do switch enum checking.
46 return leveldb::Status::InvalidArgument(msg, msg2); 46 return leveldb::Status::InvalidArgument(msg, msg2);
47 } 47 }
48 48
49 int GetLevelDBStatusUMAValue(mojom::DatabaseError status) { 49 leveldb_env::LevelDBStatusValue GetLevelDBStatusUMAValue(
50 mojom::DatabaseError status) {
50 switch (status) { 51 switch (status) {
51 case mojom::DatabaseError::OK: 52 case mojom::DatabaseError::OK:
52 return leveldb_env::LEVELDB_STATUS_OK; 53 return leveldb_env::LEVELDB_STATUS_OK;
53 case mojom::DatabaseError::NOT_FOUND: 54 case mojom::DatabaseError::NOT_FOUND:
54 return leveldb_env::LEVELDB_STATUS_NOT_FOUND; 55 return leveldb_env::LEVELDB_STATUS_NOT_FOUND;
55 case mojom::DatabaseError::CORRUPTION: 56 case mojom::DatabaseError::CORRUPTION:
56 return leveldb_env::LEVELDB_STATUS_CORRUPTION; 57 return leveldb_env::LEVELDB_STATUS_CORRUPTION;
57 case mojom::DatabaseError::NOT_SUPPORTED: 58 case mojom::DatabaseError::NOT_SUPPORTED:
58 return leveldb_env::LEVELDB_STATUS_NOT_SUPPORTED; 59 return leveldb_env::LEVELDB_STATUS_NOT_SUPPORTED;
59 case mojom::DatabaseError::INVALID_ARGUMENT: 60 case mojom::DatabaseError::INVALID_ARGUMENT:
(...skipping 23 matching lines...) Expand all
83 std::string Uint8VectorToStdString(const std::vector<uint8_t>& input) { 84 std::string Uint8VectorToStdString(const std::vector<uint8_t>& input) {
84 return std::string(reinterpret_cast<const char*>(input.data()), input.size()); 85 return std::string(reinterpret_cast<const char*>(input.data()), input.size());
85 } 86 }
86 87
87 std::vector<uint8_t> StdStringToUint8Vector(const std::string& input) { 88 std::vector<uint8_t> StdStringToUint8Vector(const std::string& input) {
88 const uint8_t* data = reinterpret_cast<const uint8_t*>(input.data()); 89 const uint8_t* data = reinterpret_cast<const uint8_t*>(input.data());
89 return std::vector<uint8_t>(data, data + input.size()); 90 return std::vector<uint8_t>(data, data + input.size());
90 } 91 }
91 92
92 } // namespace leveldb 93 } // namespace leveldb
OLDNEW
« no previous file with comments | « components/leveldb/public/cpp/util.h ('k') | components/metrics/stability_metrics_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698