| 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 EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_CHANNEL_API_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_CHANNEL_API_H_ |
| 6 #define EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_CHANNEL_API_H_ | 6 #define EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_CHANNEL_API_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 void SetSocketForTest( | 58 void SetSocketForTest( |
| 59 std::unique_ptr<cast_channel::CastSocket> socket_for_test); | 59 std::unique_ptr<cast_channel::CastSocket> socket_for_test); |
| 60 | 60 |
| 61 // Returns a test CastSocket instance, if it is defined. | 61 // Returns a test CastSocket instance, if it is defined. |
| 62 // Otherwise returns a scoped_ptr with a nullptr value. | 62 // Otherwise returns a scoped_ptr with a nullptr value. |
| 63 std::unique_ptr<cast_channel::CastSocket> GetSocketForTest(); | 63 std::unique_ptr<cast_channel::CastSocket> GetSocketForTest(); |
| 64 | 64 |
| 65 // Returns the API browser context. | 65 // Returns the API browser context. |
| 66 content::BrowserContext* GetBrowserContext() const; | 66 content::BrowserContext* GetBrowserContext() const; |
| 67 | 67 |
| 68 // Sets injected ping timeout timer for testing. | |
| 69 void SetPingTimeoutTimerForTest(std::unique_ptr<base::Timer> timer); | |
| 70 | |
| 71 // Gets the injected ping timeout timer, if set. | |
| 72 // Returns a null scoped ptr if there is no injected timer. | |
| 73 std::unique_ptr<base::Timer> GetInjectedTimeoutTimerForTest(); | |
| 74 | |
| 75 // Sends an event to the extension's EventRouter, if it exists. | 68 // Sends an event to the extension's EventRouter, if it exists. |
| 76 void SendEvent(const std::string& extension_id, std::unique_ptr<Event> event); | 69 void SendEvent(const std::string& extension_id, std::unique_ptr<Event> event); |
| 77 | 70 |
| 78 private: | 71 private: |
| 79 friend class BrowserContextKeyedAPIFactory<CastChannelAPI>; | 72 friend class BrowserContextKeyedAPIFactory<CastChannelAPI>; |
| 80 friend class ::CastChannelAPITest; | 73 friend class ::CastChannelAPITest; |
| 81 friend class CastTransportDelegate; | 74 friend class CastTransportDelegate; |
| 82 | 75 |
| 83 ~CastChannelAPI() override; | 76 ~CastChannelAPI() override; |
| 84 | 77 |
| 85 // BrowserContextKeyedAPI implementation. | 78 // BrowserContextKeyedAPI implementation. |
| 86 static const char* service_name() { return "CastChannelAPI"; } | 79 static const char* service_name() { return "CastChannelAPI"; } |
| 87 | 80 |
| 88 content::BrowserContext* const browser_context_; | 81 content::BrowserContext* const browser_context_; |
| 89 scoped_refptr<cast_channel::Logger> logger_; | 82 scoped_refptr<cast_channel::Logger> logger_; |
| 90 std::unique_ptr<cast_channel::CastSocket> socket_for_test_; | 83 std::unique_ptr<cast_channel::CastSocket> socket_for_test_; |
| 91 std::unique_ptr<base::Timer> injected_timeout_timer_; | |
| 92 | 84 |
| 93 DISALLOW_COPY_AND_ASSIGN(CastChannelAPI); | 85 DISALLOW_COPY_AND_ASSIGN(CastChannelAPI); |
| 94 }; | 86 }; |
| 95 | 87 |
| 96 class CastChannelAsyncApiFunction : public AsyncApiFunction { | 88 class CastChannelAsyncApiFunction : public AsyncApiFunction { |
| 97 public: | 89 public: |
| 98 CastChannelAsyncApiFunction(); | 90 CastChannelAsyncApiFunction(); |
| 99 | 91 |
| 100 protected: | 92 protected: |
| 101 ~CastChannelAsyncApiFunction() override; | 93 ~CastChannelAsyncApiFunction() override; |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 | 219 |
| 228 std::unique_ptr<api::cast_channel::Close::Params> params_; | 220 std::unique_ptr<api::cast_channel::Close::Params> params_; |
| 229 CastChannelAPI* api_; | 221 CastChannelAPI* api_; |
| 230 | 222 |
| 231 DISALLOW_COPY_AND_ASSIGN(CastChannelCloseFunction); | 223 DISALLOW_COPY_AND_ASSIGN(CastChannelCloseFunction); |
| 232 }; | 224 }; |
| 233 | 225 |
| 234 } // namespace extensions | 226 } // namespace extensions |
| 235 | 227 |
| 236 #endif // EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_CHANNEL_API_H_ | 228 #endif // EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_CHANNEL_API_H_ |
| OLD | NEW |