Try to work around that clang/win bug in another file.
[chromium-blink-merge.git] / components / gcm_driver / instance_id / instance_id_driver.cc
blob140d5019efd1c92e9fb09fbf444aafea74a283cc
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
3 // found in the LICENSE file.
5 #include "components/gcm_driver/instance_id/instance_id_driver.h"
7 #include "base/metrics/field_trial.h"
8 #include "components/gcm_driver/instance_id/instance_id.h"
10 namespace instance_id {
12 namespace {
13 #if !defined(OS_ANDROID)
14 const char kInstanceIDFieldTrialName[] = "InstanceID";
15 const char kInstanceIDFieldTrialEnabledGroupName[] = "Enabled";
16 #endif // !defined(OS_ANDROID)
17 } // namespace
19 // static
20 bool InstanceIDDriver::IsInstanceIDEnabled() {
21 #if defined(OS_ANDROID)
22 // Not implemented yet.
23 return false;
24 #else
25 std::string group_name =
26 base::FieldTrialList::FindFullName(kInstanceIDFieldTrialName);
27 return group_name == kInstanceIDFieldTrialEnabledGroupName;
28 #endif // defined(OS_ANDROID)
31 InstanceIDDriver::InstanceIDDriver(gcm::GCMDriver* gcm_driver)
32 : gcm_driver_(gcm_driver) {
35 InstanceIDDriver::~InstanceIDDriver() {
38 InstanceID* InstanceIDDriver::GetInstanceID(const std::string& app_id) {
39 auto iter = instance_id_map_.find(app_id);
40 if (iter != instance_id_map_.end())
41 return iter->second;
43 scoped_ptr<InstanceID> instance_id = InstanceID::Create(app_id, gcm_driver_);
44 InstanceID* instance_id_ptr = instance_id.get();
45 instance_id_map_.insert(app_id, instance_id.Pass());
46 return instance_id_ptr;
49 void InstanceIDDriver::RemoveInstanceID(const std::string& app_id) {
50 instance_id_map_.erase(app_id);
53 bool InstanceIDDriver::ExistsInstanceID(const std::string& app_id) const {
54 return instance_id_map_.find(app_id) != instance_id_map_.end();
57 } // namespace instance_id