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 #ifndef COMPONENTS_GCM_DRIVER_INSTANCE_ID_INSTANCE_ID_DRIVER_H_
6 #define COMPONENTS_GCM_DRIVER_INSTANCE_ID_INSTANCE_ID_DRIVER_H_
10 #include "base/containers/scoped_ptr_map.h"
11 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h"
18 namespace instance_id
{
22 // Bridge between Instance ID users in Chrome and the platform-specific
24 class InstanceIDDriver
{
26 // Returns whether InstanceID is enabled.
27 static bool IsInstanceIDEnabled();
29 explicit InstanceIDDriver(gcm::GCMDriver
* gcm_driver
);
30 virtual ~InstanceIDDriver();
32 // Returns the InstanceID that provides the Instance ID service for the given
33 // application. The lifetime of InstanceID will be managed by this class.
34 InstanceID
* GetInstanceID(const std::string
& app_id
);
36 // Removes the InstanceID when it is not longer needed, i.e. the app is being
38 void RemoveInstanceID(const std::string
& app_id
);
40 // Returns true if the InstanceID for the given application has been created.
41 // This is currently only used for testing purpose.
42 bool ExistsInstanceID(const std::string
& app_id
) const;
45 gcm::GCMDriver
* gcm_driver_
; // Not owned.
46 base::ScopedPtrMap
<std::string
, scoped_ptr
<InstanceID
>> instance_id_map_
;
48 DISALLOW_COPY_AND_ASSIGN(InstanceIDDriver
);
51 } // namespace instance_id
53 #endif // COMPONENTS_GCM_DRIVER_INSTANCE_ID_INSTANCE_ID_DRIVER_H_