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

Side by Side Diff: components/copresence/public/copresence_client.h

Issue 433283002: Adding the Copresence RpcHandler and HttpPost helper. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@directive-handler
Patch Set: More WeakPtr fixes Created 6 years, 4 months 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_PUBLIC_COPRESENCE_CLIENT_H_ 5 #ifndef COMPONENTS_COPRESENCE_PUBLIC_COPRESENCE_CLIENT_H_
6 #define COMPONENTS_COPRESENCE_PUBLIC_COPRESENCE_CLIENT_H_ 6 #define COMPONENTS_COPRESENCE_PUBLIC_COPRESENCE_CLIENT_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/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h"
15 #include "components/copresence/proto/rpcs.pb.h" 14 #include "components/copresence/proto/rpcs.pb.h"
16 #include "components/copresence/public/copresence_client_delegate.h" 15 #include "components/copresence/public/copresence_client_delegate.h"
17 16
18 namespace net { 17 namespace net {
19 class URLContextGetter; 18 class URLContextGetter;
20 } 19 }
21 20
22 namespace copresence { 21 namespace copresence {
23 22
24 class CopresenceClientDelegate; 23 class CopresenceClientDelegate;
25 class RpcHandler; 24 class RpcHandler;
26 25
27 struct PendingRequest { 26 struct PendingRequest {
28 PendingRequest(const copresence::ReportRequest& report, 27 PendingRequest(const copresence::ReportRequest& report,
29 const std::string app_id, 28 const std::string app_id,
30 const StatusCallback& callback); 29 const StatusCallback& callback);
31 ~PendingRequest(); 30 ~PendingRequest();
32 31
33 copresence::ReportRequest report; 32 copresence::ReportRequest report;
34 std::string app_id; 33 std::string app_id;
35 StatusCallback callback; 34 StatusCallback callback;
36 }; 35 };
37 36
38 // The CopresenceClient class is the central interface for Copresence 37 // The CopresenceClient class is the central interface for Copresence
39 // functionality. This class handles all the initialization and delegation of 38 // functionality. This class handles all the initialization and delegation of
40 // copresence tasks. Any user of copresence only needs to interact with this 39 // copresence tasks. Any user of copresence only needs to interact with this
41 // client. 40 // client.
42 class CopresenceClient : public base::SupportsWeakPtr<CopresenceClient> { 41 class CopresenceClient {
43 public: 42 public:
44 // The delegate must outlive us. 43 // The delegate must outlive us.
45 explicit CopresenceClient(CopresenceClientDelegate* delegate); 44 explicit CopresenceClient(CopresenceClientDelegate* delegate);
46 virtual ~CopresenceClient(); 45 virtual ~CopresenceClient();
47 46
48 // This method will execute a report request. Each report request can have 47 // This method will execute a report request. Each report request can have
49 // multiple (un)publishes, (un)subscribes. This will ensure that once the 48 // multiple (un)publishes, (un)subscribes. This will ensure that once the
50 // client is initialized, it sends all request to the server and handles 49 // client is initialized, it sends all request to the server and handles
51 // the response. If an error is encountered, the status callback is used 50 // the response. If an error is encountered, the status callback is used
52 // to relay it to the requester. 51 // to relay it to the requester.
(...skipping 19 matching lines...) Expand all
72 size_t pending_init_operations_; 71 size_t pending_init_operations_;
73 72
74 scoped_ptr<RpcHandler> rpc_handler_; 73 scoped_ptr<RpcHandler> rpc_handler_;
75 74
76 DISALLOW_COPY_AND_ASSIGN(CopresenceClient); 75 DISALLOW_COPY_AND_ASSIGN(CopresenceClient);
77 }; 76 };
78 77
79 } // namespace copresence 78 } // namespace copresence
80 79
81 #endif // COMPONENTS_COPRESENCE_PUBLIC_COPRESENCE_CLIENT_H_ 80 #endif // COMPONENTS_COPRESENCE_PUBLIC_COPRESENCE_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698