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

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

Issue 395333003: Extensions: Move cast_channel and hid APIs to extensions/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix win/mac Created 6 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 CHROME_BROWSER_EXTENSIONS_API_CAST_CHANNEL_CAST_CHANNEL_API_H_ 5 #ifndef EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_CHANNEL_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_CAST_CHANNEL_CAST_CHANNEL_API_H_ 6 #define EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_CHANNEL_API_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/threading/thread_checker.h" 10 #include "base/threading/thread_checker.h"
11 #include "chrome/browser/extensions/api/cast_channel/cast_socket.h"
12 #include "chrome/common/extensions/api/cast_channel.h"
13 #include "extensions/browser/api/api_resource_manager.h" 11 #include "extensions/browser/api/api_resource_manager.h"
14 #include "extensions/browser/api/async_api_function.h" 12 #include "extensions/browser/api/async_api_function.h"
13 #include "extensions/browser/api/cast_channel/cast_socket.h"
15 #include "extensions/browser/browser_context_keyed_api_factory.h" 14 #include "extensions/browser/browser_context_keyed_api_factory.h"
15 #include "extensions/common/api/cast_channel.h"
16 16
17 class GURL; 17 class GURL;
18 class CastChannelAPITest; 18 class CastChannelAPITest;
19 19
20 namespace content { 20 namespace content {
21 class BrowserContext; 21 class BrowserContext;
22 } 22 }
23 23
24 namespace net { 24 namespace net {
25 class IPEndPoint; 25 class IPEndPoint;
26 } 26 }
27 27
28 namespace extensions { 28 namespace extensions {
29 29
30 namespace cast_channel = api::cast_channel; 30 namespace cast_channel = core_api::cast_channel;
31 31
32 class CastChannelAPI : public BrowserContextKeyedAPI, 32 class CastChannelAPI : public BrowserContextKeyedAPI,
33 public cast_channel::CastSocket::Delegate { 33 public cast_channel::CastSocket::Delegate {
34
35 public: 34 public:
36 explicit CastChannelAPI(content::BrowserContext* context); 35 explicit CastChannelAPI(content::BrowserContext* context);
37 36
38 static CastChannelAPI* Get(content::BrowserContext* context); 37 static CastChannelAPI* Get(content::BrowserContext* context);
39 38
40 // BrowserContextKeyedAPI implementation. 39 // BrowserContextKeyedAPI implementation.
41 static BrowserContextKeyedAPIFactory<CastChannelAPI>* GetFactoryInstance(); 40 static BrowserContextKeyedAPIFactory<CastChannelAPI>* GetFactoryInstance();
42 41
43 // Returns a new CastSocket that connects to |ip_endpoint| with authentication 42 // Returns a new CastSocket that connects to |ip_endpoint| with authentication
44 // |channel_auth| and is to be owned by |extension_id|. 43 // |channel_auth| and is to be owned by |extension_id|.
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 virtual bool Prepare() OVERRIDE; 129 virtual bool Prepare() OVERRIDE;
131 virtual void AsyncWorkStart() OVERRIDE; 130 virtual void AsyncWorkStart() OVERRIDE;
132 131
133 private: 132 private:
134 DECLARE_EXTENSION_FUNCTION("cast.channel.open", CAST_CHANNEL_OPEN) 133 DECLARE_EXTENSION_FUNCTION("cast.channel.open", CAST_CHANNEL_OPEN)
135 134
136 // Parses the cast:// or casts:// |url|, fills |connect_info| with the 135 // Parses the cast:// or casts:// |url|, fills |connect_info| with the
137 // corresponding details, and returns true. Returns false if |url| is not a 136 // corresponding details, and returns true. Returns false if |url| is not a
138 // valid Cast URL. 137 // valid Cast URL.
139 static bool ParseChannelUrl(const GURL& url, 138 static bool ParseChannelUrl(const GURL& url,
140 api::cast_channel::ConnectInfo* connect_info); 139 cast_channel::ConnectInfo* connect_info);
141 140
142 // Validates that |connect_info| represents a valid IP end point and returns a 141 // Validates that |connect_info| represents a valid IP end point and returns a
143 // new IPEndPoint if so. Otherwise returns NULL. 142 // new IPEndPoint if so. Otherwise returns NULL.
144 static net::IPEndPoint* ParseConnectInfo( 143 static net::IPEndPoint* ParseConnectInfo(
145 const api::cast_channel::ConnectInfo& connect_info); 144 const cast_channel::ConnectInfo& connect_info);
146 145
147 void OnOpen(int result); 146 void OnOpen(int result);
148 147
149 scoped_ptr<cast_channel::Open::Params> params_; 148 scoped_ptr<cast_channel::Open::Params> params_;
150 // The id of the newly opened socket. 149 // The id of the newly opened socket.
151 int new_channel_id_; 150 int new_channel_id_;
152 CastChannelAPI* api_; 151 CastChannelAPI* api_;
153 scoped_ptr<api::cast_channel::ConnectInfo> connect_info_; 152 scoped_ptr<cast_channel::ConnectInfo> connect_info_;
154 scoped_ptr<net::IPEndPoint> ip_endpoint_; 153 scoped_ptr<net::IPEndPoint> ip_endpoint_;
155 api::cast_channel::ChannelAuthType channel_auth_; 154 cast_channel::ChannelAuthType channel_auth_;
156 155
157 FRIEND_TEST_ALL_PREFIXES(CastChannelOpenFunctionTest, TestParseChannelUrl); 156 FRIEND_TEST_ALL_PREFIXES(CastChannelOpenFunctionTest, TestParseChannelUrl);
158 FRIEND_TEST_ALL_PREFIXES(CastChannelOpenFunctionTest, TestParseConnectInfo); 157 FRIEND_TEST_ALL_PREFIXES(CastChannelOpenFunctionTest, TestParseConnectInfo);
159 DISALLOW_COPY_AND_ASSIGN(CastChannelOpenFunction); 158 DISALLOW_COPY_AND_ASSIGN(CastChannelOpenFunction);
160 }; 159 };
161 160
162 class CastChannelSendFunction : public CastChannelAsyncApiFunction { 161 class CastChannelSendFunction : public CastChannelAsyncApiFunction {
163 public: 162 public:
164 CastChannelSendFunction(); 163 CastChannelSendFunction();
165 164
(...skipping 30 matching lines...) Expand all
196 195
197 void OnClose(int result); 196 void OnClose(int result);
198 197
199 scoped_ptr<cast_channel::Close::Params> params_; 198 scoped_ptr<cast_channel::Close::Params> params_;
200 199
201 DISALLOW_COPY_AND_ASSIGN(CastChannelCloseFunction); 200 DISALLOW_COPY_AND_ASSIGN(CastChannelCloseFunction);
202 }; 201 };
203 202
204 } // namespace extensions 203 } // namespace extensions
205 204
206 #endif // CHROME_BROWSER_EXTENSIONS_API_CAST_CHANNEL_CAST_CHANNEL_API_H_ 205 #endif // EXTENSIONS_BROWSER_API_CAST_CHANNEL_CAST_CHANNEL_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698