| 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_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 <google/protobuf/repeated_field.h> | 8 #include <google/protobuf/repeated_field.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/cancelable_callback.h" | 13 #include "base/cancelable_callback.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "components/copresence/copresence_state_impl.h" | 16 #include "components/copresence/copresence_state_impl.h" |
| 17 #include "components/copresence/public/copresence_manager.h" | 17 #include "components/copresence/public/copresence_manager.h" |
| 18 #include "components/copresence/timed_map.h" | 18 #include "components/copresence/timed_map.h" |
| 19 | 19 |
| 20 namespace audio_modem { |
| 21 struct AudioToken; |
| 22 } |
| 23 |
| 20 namespace base { | 24 namespace base { |
| 21 class Timer; | 25 class Timer; |
| 22 } | 26 } |
| 23 | 27 |
| 24 namespace net { | 28 namespace net { |
| 25 class URLContextGetter; | 29 class URLContextGetter; |
| 26 } | 30 } |
| 27 | 31 |
| 28 namespace copresence { | 32 namespace copresence { |
| 29 | 33 |
| 30 class DirectiveHandler; | 34 class DirectiveHandler; |
| 31 class GCMHandler; | 35 class GCMHandler; |
| 32 class ReportRequest; | 36 class ReportRequest; |
| 33 class RpcHandler; | 37 class RpcHandler; |
| 34 class SubscribedMessage; | 38 class SubscribedMessage; |
| 35 class WhispernetClient; | |
| 36 | 39 |
| 37 // The implementation for CopresenceManager. Responsible primarily for | 40 // The implementation for CopresenceManager. Responsible primarily for |
| 38 // client-side initialization. The RpcHandler handles all the details | 41 // client-side initialization. The RpcHandler handles all the details |
| 39 // of interacting with the server. | 42 // of interacting with the server. |
| 40 // TODO(ckehoe, rkc): Add tests for this class. | 43 // TODO(ckehoe, rkc): Add tests for this class. |
| 41 class CopresenceManagerImpl : public CopresenceManager { | 44 class CopresenceManagerImpl : public CopresenceManager { |
| 42 public: | 45 public: |
| 43 // The delegate is owned by the caller, and must outlive the manager. | 46 // The delegate is owned by the caller, and must outlive the manager. |
| 44 explicit CopresenceManagerImpl(CopresenceDelegate* delegate); | 47 explicit CopresenceManagerImpl(CopresenceDelegate* delegate); |
| 45 | 48 |
| 46 ~CopresenceManagerImpl() override; | 49 ~CopresenceManagerImpl() override; |
| 47 | 50 |
| 48 // CopresenceManager overrides. | 51 // CopresenceManager overrides. |
| 49 CopresenceState* state() override; | 52 CopresenceState* state() override; |
| 50 void ExecuteReportRequest(const ReportRequest& request, | 53 void ExecuteReportRequest(const ReportRequest& request, |
| 51 const std::string& app_id, | 54 const std::string& app_id, |
| 52 const std::string& auth_token, | 55 const std::string& auth_token, |
| 53 const StatusCallback& callback) override; | 56 const StatusCallback& callback) override; |
| 54 | 57 |
| 55 private: | 58 private: |
| 56 // Complete initialization when Whispernet is available. | 59 // Complete initialization when Whispernet is available. |
| 57 void WhispernetInitComplete(bool success); | 60 void WhispernetInitComplete(bool success); |
| 58 | 61 |
| 59 // Handle tokens decoded by Whispernet. | 62 // Handle tokens decoded by Whispernet. |
| 60 // TODO(ckehoe): Replace AudioToken with ReceivedToken. | 63 // TODO(ckehoe): Replace AudioToken with ReceivedToken. |
| 61 void ReceivedTokens(const std::vector<AudioToken>& tokens); | 64 void ReceivedTokens(const std::vector<audio_modem::AudioToken>& tokens); |
| 62 | 65 |
| 63 // Verifies that we can hear the audio we're playing. | 66 // Verifies that we can hear the audio we're playing. |
| 64 // This gets called every kAudioCheckIntervalMs milliseconds. | 67 // This gets called every kAudioCheckIntervalMs milliseconds. |
| 65 void AudioCheck(); | 68 void AudioCheck(); |
| 66 | 69 |
| 67 // This gets called every kPollTimerIntervalMs milliseconds | 70 // This gets called every kPollTimerIntervalMs milliseconds |
| 68 // to poll the server for new messages. | 71 // to poll the server for new messages. |
| 69 void PollForMessages(); | 72 void PollForMessages(); |
| 70 | 73 |
| 71 // Send SubscribedMessages to the appropriate clients. | 74 // Send SubscribedMessages to the appropriate clients. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 94 | 97 |
| 95 TimedMap<std::string, google::protobuf::RepeatedPtrField<SubscribedMessage>> | 98 TimedMap<std::string, google::protobuf::RepeatedPtrField<SubscribedMessage>> |
| 96 queued_messages_by_token_; | 99 queued_messages_by_token_; |
| 97 | 100 |
| 98 DISALLOW_COPY_AND_ASSIGN(CopresenceManagerImpl); | 101 DISALLOW_COPY_AND_ASSIGN(CopresenceManagerImpl); |
| 99 }; | 102 }; |
| 100 | 103 |
| 101 } // namespace copresence | 104 } // namespace copresence |
| 102 | 105 |
| 103 #endif // COMPONENTS_COPRESENCE_COPRESENCE_MANAGER_IMPL_H_ | 106 #endif // COMPONENTS_COPRESENCE_COPRESENCE_MANAGER_IMPL_H_ |
| OLD | NEW |