1 // Copyright 2014 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_COPRESENCE_COPRESENCE_MANAGER_IMPL_H_
6 #define COMPONENTS_COPRESENCE_COPRESENCE_MANAGER_IMPL_H_
10 #include "base/cancelable_callback.h"
11 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/scoped_vector.h"
14 #include "components/copresence/public/copresence_manager.h"
17 class URLContextGetter
;
20 namespace copresence
{
22 class DirectiveHandler
;
26 struct PendingRequest
{
27 PendingRequest(const ReportRequest
& report
,
28 const std::string
& app_id
,
29 const std::string
& auth_token
,
30 const StatusCallback
& callback
);
33 scoped_ptr
<ReportRequest
> report
;
35 std::string auth_token
;
36 StatusCallback callback
;
39 // The implementation for CopresenceManager. Responsible primarily for
40 // client-side initialization. The RpcHandler handles all the details
41 // of interacting with the server.
42 class CopresenceManagerImpl
: public CopresenceManager
{
44 ~CopresenceManagerImpl() override
;
45 void ExecuteReportRequest(const ReportRequest
& request
,
46 const std::string
& app_id
,
47 const StatusCallback
& callback
) override
;
50 // Create managers with the CopresenceManager::Create() method.
51 friend class CopresenceManager
;
52 CopresenceManagerImpl(CopresenceDelegate
* delegate
);
54 void CompleteInitialization();
55 void InitStepComplete(const std::string
& step
, bool success
);
57 // Belongs to the caller.
58 CopresenceDelegate
* const delegate_
;
60 int pending_init_operations_
;
61 base::CancelableCallback
<void(bool)> whispernet_init_callback_
;
64 ScopedVector
<PendingRequest
> pending_requests_queue_
;
66 // The RpcHandler depends on the directive handler.
67 scoped_ptr
<DirectiveHandler
> directive_handler_
;
68 scoped_ptr
<RpcHandler
> rpc_handler_
;
70 DISALLOW_COPY_AND_ASSIGN(CopresenceManagerImpl
);
73 } // namespace copresence
75 #endif // COMPONENTS_COPRESENCE_COPRESENCE_MANAGER_IMPL_H_