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

Side by Side Diff: components/gcm_driver/instance_id/instance_id_driver.cc

Issue 1139633005: Make chrome.instanceID only available on dev and canary. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add missing new files Created 5 years, 7 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/gcm_driver/instance_id/instance_id_driver.h" 5 #include "components/gcm_driver/instance_id/instance_id_driver.h"
6 6
7 #include "base/metrics/field_trial.h"
8 #include "components/gcm_driver/instance_id/instance_id.h" 7 #include "components/gcm_driver/instance_id/instance_id.h"
9 8
10 namespace instance_id { 9 namespace instance_id {
11 10
12 namespace {
13 #if !defined(OS_ANDROID)
14 const char kInstanceIDFieldTrialName[] = "InstanceID";
15 const char kInstanceIDFieldTrialEnabledGroupName[] = "Enabled";
16 #endif // !defined(OS_ANDROID)
17 } // namespace
18
19 // static 11 // static
20 bool InstanceIDDriver::IsInstanceIDEnabled() { 12 bool InstanceIDDriver::IsInstanceIDEnabled() {
21 #if defined(OS_ANDROID) 13 #if defined(OS_ANDROID)
14 // Not implemented yet.
15 return false;
16 #else
22 return true; 17 return true;
23 #else
24 std::string group_name =
25 base::FieldTrialList::FindFullName(kInstanceIDFieldTrialName);
26 return group_name == kInstanceIDFieldTrialEnabledGroupName;
27 #endif // defined(OS_ANDROID) 18 #endif // defined(OS_ANDROID)
28 } 19 }
29 20
30 InstanceIDDriver::InstanceIDDriver(gcm::GCMDriver* gcm_driver) 21 InstanceIDDriver::InstanceIDDriver(gcm::GCMDriver* gcm_driver)
31 : gcm_driver_(gcm_driver), 22 : gcm_driver_(gcm_driver),
32 instance_id_map_deleter_(&instance_id_map_) { 23 instance_id_map_deleter_(&instance_id_map_) {
33 } 24 }
34 25
35 InstanceIDDriver::~InstanceIDDriver() { 26 InstanceIDDriver::~InstanceIDDriver() {
36 } 27 }
37 28
38 InstanceID* InstanceIDDriver::GetInstanceID(const std::string& app_id) { 29 InstanceID* InstanceIDDriver::GetInstanceID(const std::string& app_id) {
39 auto iter = instance_id_map_.find(app_id); 30 auto iter = instance_id_map_.find(app_id);
40 if (iter != instance_id_map_.end()) 31 if (iter != instance_id_map_.end())
41 return iter->second; 32 return iter->second;
42 33
43 InstanceID* instance_id = InstanceID::Create(app_id, gcm_driver_); 34 InstanceID* instance_id = InstanceID::Create(app_id, gcm_driver_);
44 instance_id_map_[app_id] = instance_id; 35 instance_id_map_[app_id] = instance_id;
45 return instance_id; 36 return instance_id;
46 } 37 }
47 38
48 } // namespace instance_id 39 } // namespace instance_id
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698