Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 34 std::string app_id; | 34 std::string app_id; |
| 35 StatusCallback callback; | 35 StatusCallback callback; |
| 36 }; | 36 }; |
| 37 | 37 |
| 38 // The CopresenceClient class is the central interface for Copresence | 38 // The CopresenceClient class is the central interface for Copresence |
| 39 // functionality. This class handles all the initialization and delegation of | 39 // functionality. This class handles all the initialization and delegation of |
| 40 // copresence tasks. Any user of copresence only needs to interact with this | 40 // copresence tasks. Any user of copresence only needs to interact with this |
| 41 // client. | 41 // client. |
| 42 class CopresenceClient : public base::SupportsWeakPtr<CopresenceClient> { | 42 class CopresenceClient : public base::SupportsWeakPtr<CopresenceClient> { |
| 43 public: | 43 public: |
| 44 CopresenceClient(); | |
| 45 virtual ~CopresenceClient(); | |
| 46 | |
| 44 // The delegate must outlive us. | 47 // The delegate must outlive us. |
| 45 explicit CopresenceClient(CopresenceClientDelegate* delegate); | 48 virtual void Initialize(CopresenceClientDelegate* delegate); |
|
not at google - send to devlin
2014/08/06 21:45:27
I don't really like having separate Initialize fun
Charlie
2014/08/06 21:54:41
I'm not quite following what you're suggesting. Bu
not at google - send to devlin
2014/08/06 22:02:00
I don't think my suggestion is actually implementa
Charlie
2014/08/07 22:24:15
Switching to a Create() method per the CL-level th
| |
| 46 virtual ~CopresenceClient(); | |
| 47 | 49 |
| 48 // This method will execute a report request. Each report request can have | 50 // This method will execute a report request. Each report request can have |
| 49 // multiple (un)publishes, (un)subscribes. This will ensure that once the | 51 // multiple (un)publishes, (un)subscribes. This will ensure that once the |
| 50 // client is initialized, it sends all request to the server and handles | 52 // 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 | 53 // the response. If an error is encountered, the status callback is used |
| 52 // to relay it to the requester. | 54 // to relay it to the requester. |
| 53 void ExecuteReportRequest(copresence::ReportRequest request, | 55 virtual void ExecuteReportRequest(copresence::ReportRequest request, |
| 54 const std::string& app_id, | 56 const std::string& app_id, |
| 55 const StatusCallback& callback); | 57 const StatusCallback& callback); |
| 56 | 58 |
| 57 // Called before the API (and thus the Client) is destructed. | 59 // Called before the API (and thus the Client) is destructed. |
| 58 void Shutdown(); | 60 void Shutdown(); |
| 59 | 61 |
| 60 private: | 62 private: |
| 61 void CompleteInitialization(); | 63 void CompleteInitialization(); |
| 62 void InitStepComplete(const std::string& step, bool success); | 64 void InitStepComplete(const std::string& step, bool success); |
| 63 | 65 |
| 64 CopresenceClientDelegate* delegate_; | 66 CopresenceClientDelegate* delegate_; |
| 65 bool init_failed_; | 67 bool init_failed_; |
| 66 std::vector<PendingRequest> pending_requests_queue_; | 68 std::vector<PendingRequest> pending_requests_queue_; |
| 67 | 69 |
| 68 // TODO(rkc): This code is almost identical to what we use in feedback to | 70 // TODO(rkc): This code is almost identical to what we use in feedback to |
| 69 // perform multiple blocking tasks and then run a post process method. Look | 71 // perform multiple blocking tasks and then run a post process method. Look |
| 70 // into refactoring it all out to a common construct, like maybe a | 72 // into refactoring it all out to a common construct, like maybe a |
| 71 // PostMultipleTasksAndReply? | 73 // PostMultipleTasksAndReply? |
| 72 size_t pending_init_operations_; | 74 size_t pending_init_operations_; |
| 73 | 75 |
| 74 scoped_ptr<RpcHandler> rpc_handler_; | 76 scoped_ptr<RpcHandler> rpc_handler_; |
| 75 | 77 |
| 76 DISALLOW_COPY_AND_ASSIGN(CopresenceClient); | 78 DISALLOW_COPY_AND_ASSIGN(CopresenceClient); |
| 77 }; | 79 }; |
| 78 | 80 |
| 79 } // namespace copresence | 81 } // namespace copresence |
| 80 | 82 |
| 81 #endif // COMPONENTS_COPRESENCE_PUBLIC_COPRESENCE_CLIENT_H_ | 83 #endif // COMPONENTS_COPRESENCE_PUBLIC_COPRESENCE_CLIENT_H_ |
| OLD | NEW |