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_
11 #include "base/callback.h"
12 #include "base/macros.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h"
15 #include "components/copresence/proto/rpcs.pb.h"
16 #include "components/copresence/public/copresence_manager.h"
19 class URLContextGetter
;
22 namespace copresence
{
26 struct PendingRequest
{
27 PendingRequest(const ReportRequest
& report
,
28 const std::string app_id
,
29 const StatusCallback
& callback
);
34 StatusCallback callback
;
37 // The implementation for CopresenceManager.
38 class CopresenceManagerImpl
: public CopresenceManager
,
39 public base::SupportsWeakPtr
<CopresenceManagerImpl
> {
41 virtual ~CopresenceManagerImpl();
42 virtual void ExecuteReportRequest(ReportRequest request
,
43 const std::string
& app_id
,
44 const StatusCallback
& callback
) OVERRIDE
;
47 // Create managers with the CopresenceManager::Create() method.
48 friend class CopresenceManager
;
49 CopresenceManagerImpl(CopresenceDelegate
* delegate
);
51 void CompleteInitialization();
52 void InitStepComplete(const std::string
& step
, bool success
);
55 std::vector
<PendingRequest
> pending_requests_queue_
;
57 // TODO(rkc): This code is almost identical to what we use in feedback to
58 // perform multiple blocking tasks and then run a post process method. Look
59 // into refactoring it all out to a common construct, like maybe a
60 // PostMultipleTasksAndReply?
61 size_t pending_init_operations_
;
63 CopresenceDelegate
* const delegate_
;
64 scoped_ptr
<RpcHandler
> rpc_handler_
;
66 DISALLOW_COPY_AND_ASSIGN(CopresenceManagerImpl
);
69 } // namespace copresence
71 #endif // COMPONENTS_COPRESENCE_COPRESENCE_MANAGER_IMPL_H_