Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(209)

Side by Side Diff: components/copresence/copresence_manager_impl.h

Issue 671573003: Adding support for authenticated copresence calls (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing memory error Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 #ifndef COMPONENTS_COPRESENCE_COPRESENCE_MANAGER_IMPL_H_ 5 #ifndef COMPONENTS_COPRESENCE_COPRESENCE_MANAGER_IMPL_H_
6 #define COMPONENTS_COPRESENCE_COPRESENCE_MANAGER_IMPL_H_ 6 #define COMPONENTS_COPRESENCE_COPRESENCE_MANAGER_IMPL_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/cancelable_callback.h" 12 #include "base/cancelable_callback.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/scoped_vector.h"
15 #include "components/copresence/proto/rpcs.pb.h" 16 #include "components/copresence/proto/rpcs.pb.h"
16 #include "components/copresence/public/copresence_manager.h" 17 #include "components/copresence/public/copresence_manager.h"
17 18
18 namespace net { 19 namespace net {
19 class URLContextGetter; 20 class URLContextGetter;
20 } 21 }
21 22
22 namespace copresence { 23 namespace copresence {
23 24
24 class RpcHandler; 25 class RpcHandler;
25 26
26 struct PendingRequest { 27 struct PendingRequest {
27 PendingRequest(const ReportRequest& report, 28 PendingRequest(const ReportRequest& report,
28 const std::string app_id, 29 const std::string& app_id,
30 const std::string& auth_token,
29 const StatusCallback& callback); 31 const StatusCallback& callback);
30 ~PendingRequest(); 32 ~PendingRequest();
31 33
32 ReportRequest report; 34 scoped_ptr<ReportRequest> report;
33 std::string app_id; 35 std::string app_id;
36 std::string auth_token;
34 StatusCallback callback; 37 StatusCallback callback;
35 }; 38 };
36 39
37 // The implementation for CopresenceManager. 40 // The implementation for CopresenceManager. Responsible primarily for
41 // client-side initialization. The RpcHandler handles all the details
42 // of interacting with the server.
38 class CopresenceManagerImpl : public CopresenceManager { 43 class CopresenceManagerImpl : public CopresenceManager {
39 public: 44 public:
40 ~CopresenceManagerImpl() override; 45 ~CopresenceManagerImpl() override;
41 void ExecuteReportRequest(ReportRequest request, 46 void ExecuteReportRequest(const ReportRequest& request,
42 const std::string& app_id, 47 const std::string& app_id,
43 const StatusCallback& callback) override; 48 const StatusCallback& callback) override;
44 49
45 private: 50 private:
46 // Create managers with the CopresenceManager::Create() method. 51 // Create managers with the CopresenceManager::Create() method.
47 friend class CopresenceManager; 52 friend class CopresenceManager;
48 CopresenceManagerImpl(CopresenceDelegate* delegate); 53 CopresenceManagerImpl(CopresenceDelegate* delegate);
49 54
50 void CompleteInitialization(); 55 void CompleteInitialization();
51 void InitStepComplete(const std::string& step, bool success); 56 void InitStepComplete(const std::string& step, bool success);
52 57
53 bool init_failed_; 58 bool init_failed_;
54 std::vector<PendingRequest> pending_requests_queue_; 59 ScopedVector<PendingRequest> pending_requests_queue_;
55 60
56 base::CancelableCallback<void(bool)> init_callback_; 61 base::CancelableCallback<void(bool)> whispernet_init_callback_;
57 62
58 // TODO(rkc): This code is almost identical to what we use in feedback to 63 // TODO(rkc): This code is almost identical to what we use in feedback to
59 // perform multiple blocking tasks and then run a post process method. Look 64 // perform multiple blocking tasks and then run a post process method. Look
60 // into refactoring it all out to a common construct, like maybe a 65 // into refactoring it all out to a common construct, like maybe a
61 // PostMultipleTasksAndReply? 66 // PostMultipleTasksAndReply?
62 size_t pending_init_operations_; 67 int pending_init_operations_;
63 68
64 CopresenceDelegate* const delegate_; 69 CopresenceDelegate* const delegate_;
65 scoped_ptr<RpcHandler> rpc_handler_; 70 scoped_ptr<RpcHandler> rpc_handler_;
66 71
67 DISALLOW_COPY_AND_ASSIGN(CopresenceManagerImpl); 72 DISALLOW_COPY_AND_ASSIGN(CopresenceManagerImpl);
68 }; 73 };
69 74
70 } // namespace copresence 75 } // namespace copresence
71 76
72 #endif // COMPONENTS_COPRESENCE_COPRESENCE_MANAGER_IMPL_H_ 77 #endif // COMPONENTS_COPRESENCE_COPRESENCE_MANAGER_IMPL_H_
OLDNEW
« no previous file with comments | « components/copresence/copresence_manager.cc ('k') | components/copresence/copresence_manager_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698