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

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

Issue 1128123003: Implement InstanceID API functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test 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"
7 #include "components/gcm_driver/instance_id/instance_id.h" 8 #include "components/gcm_driver/instance_id/instance_id.h"
8 9
9 namespace instance_id { 10 namespace instance_id {
10 11
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
20 bool InstanceIDDriver::IsInstanceIDEnabled() {
21 #if defined(OS_ANDROID)
22 return true;
23 #else
24 std::string group_name =
25 base::FieldTrialList::FindFullName(kInstanceIDFieldTrialName);
26 return group_name == kInstanceIDFieldTrialEnabledGroupName;
27 #endif // defined(OS_ANDROID)
28 }
29
11 InstanceIDDriver::InstanceIDDriver(gcm::GCMDriver* gcm_driver) 30 InstanceIDDriver::InstanceIDDriver(gcm::GCMDriver* gcm_driver)
12 : gcm_driver_(gcm_driver), 31 : gcm_driver_(gcm_driver),
13 instance_id_map_deleter_(&instance_id_map_) { 32 instance_id_map_deleter_(&instance_id_map_) {
14 } 33 }
15 34
16 InstanceIDDriver::~InstanceIDDriver() { 35 InstanceIDDriver::~InstanceIDDriver() {
17 } 36 }
18 37
19 InstanceID* InstanceIDDriver::GetInstanceID(const std::string& app_id) { 38 InstanceID* InstanceIDDriver::GetInstanceID(const std::string& app_id) {
20 auto iter = instance_id_map_.find(app_id); 39 auto iter = instance_id_map_.find(app_id);
21 if (iter != instance_id_map_.end()) 40 if (iter != instance_id_map_.end())
22 return iter->second; 41 return iter->second;
23 42
24 InstanceID* instance_id = InstanceID::Create(app_id, gcm_driver_); 43 InstanceID* instance_id = InstanceID::Create(app_id, gcm_driver_);
25 instance_id_map_[app_id] = instance_id; 44 instance_id_map_[app_id] = instance_id;
26 return instance_id; 45 return instance_id;
27 } 46 }
28 47
29 } // namespace instance_id 48 } // namespace instance_id
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698