OLD | NEW |
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 "base/metrics/field_trial.h" |
| 8 #include "base/strings/string_util.h" |
8 #include "build/build_config.h" | 9 #include "build/build_config.h" |
9 #include "components/gcm_driver/gcm_driver.h" | 10 #include "components/gcm_driver/gcm_driver.h" |
10 #include "components/gcm_driver/instance_id/instance_id.h" | 11 #include "components/gcm_driver/instance_id/instance_id.h" |
11 | 12 |
12 namespace instance_id { | 13 namespace instance_id { |
13 | 14 |
14 namespace { | 15 namespace { |
15 const char kInstanceIDFieldTrialName[] = "InstanceID"; | 16 const char kInstanceIDFieldTrialName[] = "InstanceID"; |
16 const char kInstanceIDFieldTrialEnabledGroupName[] = "Enabled"; | 17 const char kInstanceIDFieldTrialDisabledGroupPrefix[] = "Disabled"; |
17 } // namespace | 18 } // namespace |
18 | 19 |
19 // static | 20 // static |
20 bool InstanceIDDriver::IsInstanceIDEnabled() { | 21 bool InstanceIDDriver::IsInstanceIDEnabled() { |
21 std::string group_name = | 22 std::string group_name = |
22 base::FieldTrialList::FindFullName(kInstanceIDFieldTrialName); | 23 base::FieldTrialList::FindFullName(kInstanceIDFieldTrialName); |
23 return group_name == kInstanceIDFieldTrialEnabledGroupName; | 24 return !base::StartsWith(group_name, kInstanceIDFieldTrialDisabledGroupPrefix, |
| 25 base::CompareCase::INSENSITIVE_ASCII); |
24 } | 26 } |
25 | 27 |
26 InstanceIDDriver::InstanceIDDriver(gcm::GCMDriver* gcm_driver) | 28 InstanceIDDriver::InstanceIDDriver(gcm::GCMDriver* gcm_driver) |
27 : gcm_driver_(gcm_driver) { | 29 : gcm_driver_(gcm_driver) { |
28 } | 30 } |
29 | 31 |
30 InstanceIDDriver::~InstanceIDDriver() { | 32 InstanceIDDriver::~InstanceIDDriver() { |
31 } | 33 } |
32 | 34 |
33 InstanceID* InstanceIDDriver::GetInstanceID(const std::string& app_id) { | 35 InstanceID* InstanceIDDriver::GetInstanceID(const std::string& app_id) { |
(...skipping 11 matching lines...) Expand all Loading... |
45 | 47 |
46 void InstanceIDDriver::RemoveInstanceID(const std::string& app_id) { | 48 void InstanceIDDriver::RemoveInstanceID(const std::string& app_id) { |
47 instance_id_map_.erase(app_id); | 49 instance_id_map_.erase(app_id); |
48 } | 50 } |
49 | 51 |
50 bool InstanceIDDriver::ExistsInstanceID(const std::string& app_id) const { | 52 bool InstanceIDDriver::ExistsInstanceID(const std::string& app_id) const { |
51 return instance_id_map_.find(app_id) != instance_id_map_.end(); | 53 return instance_id_map_.find(app_id) != instance_id_map_.end(); |
52 } | 54 } |
53 | 55 |
54 } // namespace instance_id | 56 } // namespace instance_id |
OLD | NEW |