OLD | NEW |
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 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "chrome/browser/browser_process.h" | |
15 #include "chrome/browser/extensions/api/cast_channel/cast_socket.h" | |
16 #include "chrome/browser/net/chrome_net_log.h" | |
17 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
| 15 #include "extensions/browser/api/cast_channel/cast_socket.h" |
18 #include "extensions/browser/event_router.h" | 16 #include "extensions/browser/event_router.h" |
19 #include "net/base/ip_endpoint.h" | 17 #include "net/base/ip_endpoint.h" |
20 #include "net/base/net_errors.h" | 18 #include "net/base/net_errors.h" |
21 #include "net/base/net_util.h" | 19 #include "net/base/net_util.h" |
22 #include "url/gurl.h" | 20 #include "url/gurl.h" |
23 | 21 |
24 // Default timeout interval for connection setup. | 22 // Default timeout interval for connection setup. |
25 // Used if not otherwise specified at ConnectInfo::timeout. | 23 // Used if not otherwise specified at ConnectInfo::timeout. |
26 const int kDefaultConnectTimeoutMillis = 5000; // 5 seconds. | 24 const int kDefaultConnectTimeoutMillis = 5000; // 5 seconds. |
27 | 25 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 } | 100 } |
103 | 101 |
104 scoped_ptr<CastSocket> CastChannelAPI::CreateCastSocket( | 102 scoped_ptr<CastSocket> CastChannelAPI::CreateCastSocket( |
105 const std::string& extension_id, const net::IPEndPoint& ip_endpoint, | 103 const std::string& extension_id, const net::IPEndPoint& ip_endpoint, |
106 ChannelAuthType channel_auth, const base::TimeDelta& timeout) { | 104 ChannelAuthType channel_auth, const base::TimeDelta& timeout) { |
107 if (socket_for_test_.get()) { | 105 if (socket_for_test_.get()) { |
108 return socket_for_test_.Pass(); | 106 return socket_for_test_.Pass(); |
109 } else { | 107 } else { |
110 return scoped_ptr<CastSocket>( | 108 return scoped_ptr<CastSocket>( |
111 new CastSocket(extension_id, ip_endpoint, channel_auth, this, | 109 new CastSocket(extension_id, ip_endpoint, channel_auth, this, |
112 g_browser_process->net_log(), | 110 ExtensionsBrowserClient::Get()->GetNetLog(), |
113 timeout)); | 111 timeout)); |
114 } | 112 } |
115 } | 113 } |
116 | 114 |
117 void CastChannelAPI::SetSocketForTest(scoped_ptr<CastSocket> socket_for_test) { | 115 void CastChannelAPI::SetSocketForTest(scoped_ptr<CastSocket> socket_for_test) { |
118 socket_for_test_ = socket_for_test.Pass(); | 116 socket_for_test_ = socket_for_test.Pass(); |
119 } | 117 } |
120 | 118 |
121 void CastChannelAPI::OnError(const CastSocket* socket, | 119 void CastChannelAPI::OnError(const CastSocket* socket, |
122 cast_channel::ChannelError error) { | 120 cast_channel::ChannelError error) { |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 SetResultFromError(cast_channel::CHANNEL_ERROR_SOCKET_ERROR); | 414 SetResultFromError(cast_channel::CHANNEL_ERROR_SOCKET_ERROR); |
417 } else { | 415 } else { |
418 int channel_id = params_->channel.channel_id; | 416 int channel_id = params_->channel.channel_id; |
419 SetResultFromSocket(channel_id); | 417 SetResultFromSocket(channel_id); |
420 RemoveSocket(channel_id); | 418 RemoveSocket(channel_id); |
421 } | 419 } |
422 AsyncWorkCompleted(); | 420 AsyncWorkCompleted(); |
423 } | 421 } |
424 | 422 |
425 } // namespace extensions | 423 } // namespace extensions |
OLD | NEW |