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 <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 } | 24 } |
25 | 25 |
26 namespace net { | 26 namespace net { |
27 class IPEndPoint; | 27 class IPEndPoint; |
28 } | 28 } |
29 | 29 |
30 namespace extensions { | 30 namespace extensions { |
31 | 31 |
32 struct Event; | 32 struct Event; |
33 | 33 |
34 namespace core_api { | 34 namespace api { |
35 namespace cast_channel { | 35 namespace cast_channel { |
36 class Logger; | 36 class Logger; |
37 } // namespace cast_channel | 37 } // namespace cast_channel |
38 } // namespace core_api | 38 } // namespace api |
39 | 39 |
40 namespace cast_channel = core_api::cast_channel; | 40 namespace cast_channel = api::cast_channel; |
41 | 41 |
42 class CastChannelAPI : public BrowserContextKeyedAPI, | 42 class CastChannelAPI : public BrowserContextKeyedAPI, |
43 public base::SupportsWeakPtr<CastChannelAPI> { | 43 public base::SupportsWeakPtr<CastChannelAPI> { |
44 public: | 44 public: |
45 explicit CastChannelAPI(content::BrowserContext* context); | 45 explicit CastChannelAPI(content::BrowserContext* context); |
46 | 46 |
47 static CastChannelAPI* Get(content::BrowserContext* context); | 47 static CastChannelAPI* Get(content::BrowserContext* context); |
48 | 48 |
49 // BrowserContextKeyedAPI implementation. | 49 // BrowserContextKeyedAPI implementation. |
50 static BrowserContextKeyedAPIFactory<CastChannelAPI>* GetFactoryInstance(); | 50 static BrowserContextKeyedAPIFactory<CastChannelAPI>* GetFactoryInstance(); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 // Parameter #1 is a scoped pointer to the event payload. | 160 // Parameter #1 is a scoped pointer to the event payload. |
161 using EventDispatchCallback = | 161 using EventDispatchCallback = |
162 base::Callback<void(const std::string&, scoped_ptr<Event>)>; | 162 base::Callback<void(const std::string&, scoped_ptr<Event>)>; |
163 | 163 |
164 // Receives incoming messages and errors and provides additional API and | 164 // Receives incoming messages and errors and provides additional API and |
165 // origin socket context. | 165 // origin socket context. |
166 class CastMessageHandler : public cast_channel::CastTransport::Delegate { | 166 class CastMessageHandler : public cast_channel::CastTransport::Delegate { |
167 public: | 167 public: |
168 CastMessageHandler(const EventDispatchCallback& ui_dispatch_cb, | 168 CastMessageHandler(const EventDispatchCallback& ui_dispatch_cb, |
169 cast_channel::CastSocket* socket, | 169 cast_channel::CastSocket* socket, |
170 scoped_refptr<core_api::cast_channel::Logger> logger); | 170 scoped_refptr<api::cast_channel::Logger> logger); |
171 ~CastMessageHandler() override; | 171 ~CastMessageHandler() override; |
172 | 172 |
173 // CastTransport::Delegate implementation. | 173 // CastTransport::Delegate implementation. |
174 void OnError(cast_channel::ChannelError error_state) override; | 174 void OnError(cast_channel::ChannelError error_state) override; |
175 void OnMessage(const cast_channel::CastMessage& message) override; | 175 void OnMessage(const cast_channel::CastMessage& message) override; |
176 void Start() override; | 176 void Start() override; |
177 | 177 |
178 private: | 178 private: |
179 // Callback for sending events to the extension. | 179 // Callback for sending events to the extension. |
180 // Should be bound to a weak pointer, to prevent any use-after-free | 180 // Should be bound to a weak pointer, to prevent any use-after-free |
181 // conditions. | 181 // conditions. |
182 EventDispatchCallback const ui_dispatch_cb_; | 182 EventDispatchCallback const ui_dispatch_cb_; |
183 cast_channel::CastSocket* const socket_; | 183 cast_channel::CastSocket* const socket_; |
184 // Logger object for reporting error details. | 184 // Logger object for reporting error details. |
185 scoped_refptr<core_api::cast_channel::Logger> logger_; | 185 scoped_refptr<api::cast_channel::Logger> logger_; |
186 | 186 |
187 DISALLOW_COPY_AND_ASSIGN(CastMessageHandler); | 187 DISALLOW_COPY_AND_ASSIGN(CastMessageHandler); |
188 }; | 188 }; |
189 | 189 |
190 // Validates that |connect_info| represents a valid IP end point and returns a | 190 // Validates that |connect_info| represents a valid IP end point and returns a |
191 // new IPEndPoint if so. Otherwise returns nullptr. | 191 // new IPEndPoint if so. Otherwise returns nullptr. |
192 static net::IPEndPoint* ParseConnectInfo( | 192 static net::IPEndPoint* ParseConnectInfo( |
193 const cast_channel::ConnectInfo& connect_info); | 193 const cast_channel::ConnectInfo& connect_info); |
194 | 194 |
195 void OnOpen(cast_channel::ChannelError result); | 195 void OnOpen(cast_channel::ChannelError result); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 CAST_CHANNEL_SETAUTHORITYKEYS) | 285 CAST_CHANNEL_SETAUTHORITYKEYS) |
286 | 286 |
287 scoped_ptr<cast_channel::SetAuthorityKeys::Params> params_; | 287 scoped_ptr<cast_channel::SetAuthorityKeys::Params> params_; |
288 | 288 |
289 DISALLOW_COPY_AND_ASSIGN(CastChannelSetAuthorityKeysFunction); | 289 DISALLOW_COPY_AND_ASSIGN(CastChannelSetAuthorityKeysFunction); |
290 }; | 290 }; |
291 | 291 |
292 } // namespace extensions | 292 } // namespace extensions |
293 | 293 |
294 #endif // EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_CHANNEL_API_H_ | 294 #endif // EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_CHANNEL_API_H_ |
OLD | NEW |