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

Unified Diff: chrome/browser/metrics/variations/generated_resources_map_lookup.cc

Issue 370463003: Add support for variations controlled overriding UI strings to the variations service. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/metrics/variations/generated_resources_map_lookup.cc
diff --git a/chrome/browser/metrics/variations/generated_resources_map_lookup.cc b/chrome/browser/metrics/variations/generated_resources_map_lookup.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7f96b7e3969cb257745b6714661ddeb03d83aa34
--- /dev/null
+++ b/chrome/browser/metrics/variations/generated_resources_map_lookup.cc
@@ -0,0 +1,20 @@
+// Copyright 2014 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.
+
+#include "chrome/browser/metrics/variations/generated_resources_map.h"
+
+#include <algorithm>
+
+namespace chrome_variations {
+
+int GetResourceIndex(uint32_t hash) {
+ const uint32_t* kEnd = kResourceHashes + kNumResources;
+ const uint32_t* kElement = std::lower_bound(kResourceHashes, kEnd, hash);
Alexei Svitkine (slow) 2014/07/03 17:54:40 Nit: kNaming convention is only used for compile-t
jwd 2014/07/07 15:52:20 Done.
+
+ if (kElement == kEnd || *kElement != hash)
Alexei Svitkine (slow) 2014/07/03 17:54:40 Is the first cond needed or will the second catch
jwd 2014/07/07 15:52:20 If element == kEnd, then it would be dereferencing
+ return -1;
+ return kResourceIndices[kElement - kResourceHashes];
Alexei Svitkine (slow) 2014/07/03 17:54:40 Nit: Remove extra space after return.
jwd 2014/07/07 15:52:20 Done.
+}
+
+} // namespace chrome_variations

Powered by Google App Engine
This is Rietveld 408576698