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

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

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 #include "chrome/browser/extensions/api/cast_channel/cast_channel_api.h" 5 #include "extensions/browser/api/cast_channel/cast_channel_api.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/extensions/api/cast_channel/cast_socket.h"
15 #include "chrome/browser/net/chrome_net_log.h"
16 #include "content/public/browser/browser_thread.h" 13 #include "content/public/browser/browser_thread.h"
14 #include "extensions/browser/api/cast_channel/cast_socket.h"
17 #include "extensions/browser/event_router.h" 15 #include "extensions/browser/event_router.h"
18 #include "net/base/ip_endpoint.h" 16 #include "net/base/ip_endpoint.h"
19 #include "net/base/net_errors.h" 17 #include "net/base/net_errors.h"
20 #include "net/base/net_util.h" 18 #include "net/base/net_util.h"
21 #include "url/gurl.h" 19 #include "url/gurl.h"
22 20
23 namespace extensions { 21 namespace extensions {
24 22
25 namespace Close = cast_channel::Close; 23 namespace Close = cast_channel::Close;
26 namespace OnError = cast_channel::OnError; 24 namespace OnError = cast_channel::OnError;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 } 80 }
83 81
84 scoped_ptr<CastSocket> CastChannelAPI::CreateCastSocket( 82 scoped_ptr<CastSocket> CastChannelAPI::CreateCastSocket(
85 const std::string& extension_id, const net::IPEndPoint& ip_endpoint, 83 const std::string& extension_id, const net::IPEndPoint& ip_endpoint,
86 ChannelAuthType channel_auth) { 84 ChannelAuthType channel_auth) {
87 if (socket_for_test_.get()) { 85 if (socket_for_test_.get()) {
88 return socket_for_test_.Pass(); 86 return socket_for_test_.Pass();
89 } else { 87 } else {
90 return scoped_ptr<CastSocket>( 88 return scoped_ptr<CastSocket>(
91 new CastSocket(extension_id, ip_endpoint, channel_auth, this, 89 new CastSocket(extension_id, ip_endpoint, channel_auth, this,
92 g_browser_process->net_log())); 90 ExtensionsBrowserClient::Get()->GetNetLog()));
93 } 91 }
94 } 92 }
95 93
96 void CastChannelAPI::SetSocketForTest(scoped_ptr<CastSocket> socket_for_test) { 94 void CastChannelAPI::SetSocketForTest(scoped_ptr<CastSocket> socket_for_test) {
97 socket_for_test_ = socket_for_test.Pass(); 95 socket_for_test_ = socket_for_test.Pass();
98 } 96 }
99 97
100 void CastChannelAPI::OnError(const CastSocket* socket, 98 void CastChannelAPI::OnError(const CastSocket* socket,
101 cast_channel::ChannelError error) { 99 cast_channel::ChannelError error) {
102 DCHECK_CURRENTLY_ON(BrowserThread::IO); 100 DCHECK_CURRENTLY_ON(BrowserThread::IO);
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 VLOG(2) << "IP: " << ip_address_str << " Port: " << port_str; 235 VLOG(2) << "IP: " << ip_address_str << " Port: " << port_str;
238 int port; 236 int port;
239 if (!base::StringToInt(port_str, &port)) 237 if (!base::StringToInt(port_str, &port))
240 return false; 238 return false;
241 connect_info->ip_address = ip_address_str; 239 connect_info->ip_address = ip_address_str;
242 connect_info->port = port; 240 connect_info->port = port;
243 connect_info->auth = auth_required ? 241 connect_info->auth = auth_required ?
244 cast_channel::CHANNEL_AUTH_TYPE_SSL_VERIFIED : 242 cast_channel::CHANNEL_AUTH_TYPE_SSL_VERIFIED :
245 cast_channel::CHANNEL_AUTH_TYPE_SSL; 243 cast_channel::CHANNEL_AUTH_TYPE_SSL;
246 return true; 244 return true;
247 }; 245 }
248 246
249 net::IPEndPoint* CastChannelOpenFunction::ParseConnectInfo( 247 net::IPEndPoint* CastChannelOpenFunction::ParseConnectInfo(
250 const ConnectInfo& connect_info) { 248 const ConnectInfo& connect_info) {
251 net::IPAddressNumber ip_address; 249 net::IPAddressNumber ip_address;
252 if (!net::ParseIPLiteralToNumber(connect_info.ip_address, &ip_address)) { 250 if (!net::ParseIPLiteralToNumber(connect_info.ip_address, &ip_address)) {
253 return NULL; 251 return NULL;
254 } 252 }
255 if (connect_info.port < 0 || connect_info.port > 253 if (connect_info.port < 0 || connect_info.port >
256 std::numeric_limits<unsigned short>::max()) { 254 std::numeric_limits<unsigned short>::max()) {
257 return NULL; 255 return NULL;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 SetResultFromError(cast_channel::CHANNEL_ERROR_SOCKET_ERROR); 362 SetResultFromError(cast_channel::CHANNEL_ERROR_SOCKET_ERROR);
365 } else { 363 } else {
366 int channel_id = params_->channel.channel_id; 364 int channel_id = params_->channel.channel_id;
367 SetResultFromSocket(channel_id); 365 SetResultFromSocket(channel_id);
368 RemoveSocket(channel_id); 366 RemoveSocket(channel_id);
369 } 367 }
370 AsyncWorkCompleted(); 368 AsyncWorkCompleted();
371 } 369 }
372 370
373 } // namespace extensions 371 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698