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

Side by Side Diff: extensions/browser/api/cast_channel/cast_channel_api.h

Issue 2891923004: [cast_channel] Make cast_channel related files not depend on "cast_channel.h" (Closed)
Patch Set: rename cast_channel_type to cast_channel_enum Created 3 years, 7 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 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
11 #include "base/gtest_prod_util.h" 11 #include "base/gtest_prod_util.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/threading/thread_checker.h" 14 #include "base/threading/thread_checker.h"
15 #include "components/cast_channel/cast_channel_enum.h"
15 #include "extensions/browser/api/api_resource_manager.h" 16 #include "extensions/browser/api/api_resource_manager.h"
16 #include "extensions/browser/api/async_api_function.h" 17 #include "extensions/browser/api/async_api_function.h"
17 #include "extensions/browser/api/cast_channel/cast_socket.h" 18 #include "extensions/browser/api/cast_channel/cast_socket.h"
18 #include "extensions/browser/browser_context_keyed_api_factory.h" 19 #include "extensions/browser/browser_context_keyed_api_factory.h"
19 #include "extensions/common/api/cast_channel.h" 20 #include "extensions/common/api/cast_channel.h"
20 21
21 class CastChannelAPITest; 22 class CastChannelAPITest;
22 23
23 namespace content { 24 namespace content {
24 class BrowserContext; 25 class BrowserContext;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 // Receives incoming messages and errors and provides additional API and 170 // Receives incoming messages and errors and provides additional API and
170 // origin socket context. 171 // origin socket context.
171 class CastMessageHandler : public cast_channel::CastTransport::Delegate { 172 class CastMessageHandler : public cast_channel::CastTransport::Delegate {
172 public: 173 public:
173 CastMessageHandler(const EventDispatchCallback& ui_dispatch_cb, 174 CastMessageHandler(const EventDispatchCallback& ui_dispatch_cb,
174 cast_channel::CastSocket* socket, 175 cast_channel::CastSocket* socket,
175 scoped_refptr<api::cast_channel::Logger> logger); 176 scoped_refptr<api::cast_channel::Logger> logger);
176 ~CastMessageHandler() override; 177 ~CastMessageHandler() override;
177 178
178 // CastTransport::Delegate implementation. 179 // CastTransport::Delegate implementation.
179 void OnError(cast_channel::ChannelError error_state) override; 180 void OnError(::cast_channel::ChannelError error_state) override;
180 void OnMessage(const cast_channel::CastMessage& message) override; 181 void OnMessage(const cast_channel::CastMessage& message) override;
181 void Start() override; 182 void Start() override;
182 183
183 private: 184 private:
184 // Callback for sending events to the extension. 185 // Callback for sending events to the extension.
185 // Should be bound to a weak pointer, to prevent any use-after-free 186 // Should be bound to a weak pointer, to prevent any use-after-free
186 // conditions. 187 // conditions.
187 EventDispatchCallback const ui_dispatch_cb_; 188 EventDispatchCallback const ui_dispatch_cb_;
188 cast_channel::CastSocket* const socket_; 189 cast_channel::CastSocket* const socket_;
189 // Logger object for reporting error details. 190 // Logger object for reporting error details.
190 scoped_refptr<api::cast_channel::Logger> logger_; 191 scoped_refptr<api::cast_channel::Logger> logger_;
191 192
192 DISALLOW_COPY_AND_ASSIGN(CastMessageHandler); 193 DISALLOW_COPY_AND_ASSIGN(CastMessageHandler);
193 }; 194 };
194 195
195 // Validates that |connect_info| represents a valid IP end point and returns a 196 // Validates that |connect_info| represents a valid IP end point and returns a
196 // new IPEndPoint if so. Otherwise returns nullptr. 197 // new IPEndPoint if so. Otherwise returns nullptr.
197 static net::IPEndPoint* ParseConnectInfo( 198 static net::IPEndPoint* ParseConnectInfo(
198 const cast_channel::ConnectInfo& connect_info); 199 const cast_channel::ConnectInfo& connect_info);
199 200
200 void OnOpen(cast_channel::ChannelError result); 201 void OnOpen(::cast_channel::ChannelError result);
201 202
202 std::unique_ptr<cast_channel::Open::Params> params_; 203 std::unique_ptr<cast_channel::Open::Params> params_;
203 // The id of the newly opened socket. 204 // The id of the newly opened socket.
204 int new_channel_id_; 205 int new_channel_id_;
205 CastChannelAPI* api_; 206 CastChannelAPI* api_;
206 std::unique_ptr<net::IPEndPoint> ip_endpoint_; 207 std::unique_ptr<net::IPEndPoint> ip_endpoint_;
207 cast_channel::ChannelAuthType channel_auth_; 208 ::cast_channel::ChannelAuthType channel_auth_;
208 base::TimeDelta liveness_timeout_; 209 base::TimeDelta liveness_timeout_;
209 base::TimeDelta ping_interval_; 210 base::TimeDelta ping_interval_;
210 211
211 FRIEND_TEST_ALL_PREFIXES(CastChannelOpenFunctionTest, TestParseConnectInfo); 212 FRIEND_TEST_ALL_PREFIXES(CastChannelOpenFunctionTest, TestParseConnectInfo);
212 DISALLOW_COPY_AND_ASSIGN(CastChannelOpenFunction); 213 DISALLOW_COPY_AND_ASSIGN(CastChannelOpenFunction);
213 }; 214 };
214 215
215 class CastChannelSendFunction : public CastChannelAsyncApiFunction { 216 class CastChannelSendFunction : public CastChannelAsyncApiFunction {
216 public: 217 public:
217 CastChannelSendFunction(); 218 CastChannelSendFunction();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 253
253 std::unique_ptr<cast_channel::Close::Params> params_; 254 std::unique_ptr<cast_channel::Close::Params> params_;
254 CastChannelAPI* api_; 255 CastChannelAPI* api_;
255 256
256 DISALLOW_COPY_AND_ASSIGN(CastChannelCloseFunction); 257 DISALLOW_COPY_AND_ASSIGN(CastChannelCloseFunction);
257 }; 258 };
258 259
259 } // namespace extensions 260 } // namespace extensions
260 261
261 #endif // EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_CHANNEL_API_H_ 262 #endif // EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_CHANNEL_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698