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 #include "extensions/browser/api/cast_channel/cast_channel_api.h" | 5 #include "extensions/browser/api/cast_channel/cast_channel_api.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <limits> | 10 #include <limits> |
11 #include <string> | 11 #include <string> |
12 #include <utility> | 12 #include <utility> |
13 | 13 |
14 #include "base/json/json_writer.h" | 14 #include "base/json/json_writer.h" |
15 #include "base/lazy_instance.h" | 15 #include "base/lazy_instance.h" |
16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
17 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
18 #include "base/time/default_clock.h" | 18 #include "base/time/default_clock.h" |
19 #include "base/values.h" | 19 #include "base/values.h" |
20 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
21 #include "extensions/browser/api/cast_channel/cast_auth_ica.h" | 21 #include "extensions/browser/api/cast_channel/cast_auth_ica.h" |
22 #include "extensions/browser/api/cast_channel/cast_message_util.h" | 22 #include "extensions/browser/api/cast_channel/cast_message_util.h" |
23 #include "extensions/browser/api/cast_channel/cast_socket.h" | 23 #include "extensions/browser/api/cast_channel/cast_socket.h" |
24 #include "extensions/browser/api/cast_channel/keep_alive_delegate.h" | 24 #include "extensions/browser/api/cast_channel/keep_alive_delegate.h" |
25 #include "extensions/browser/api/cast_channel/logger.h" | 25 #include "extensions/browser/api/cast_channel/logger.h" |
26 #include "extensions/browser/event_router.h" | 26 #include "extensions/browser/event_router.h" |
27 #include "extensions/common/api/cast_channel/cast_channel.pb.h" | 27 #include "extensions/common/api/cast_channel/cast_channel.pb.h" |
28 #include "extensions/common/api/cast_channel/logging.pb.h" | 28 #include "extensions/common/api/cast_channel/logging.pb.h" |
| 29 #include "net/base/ip_address.h" |
29 #include "net/base/ip_endpoint.h" | 30 #include "net/base/ip_endpoint.h" |
30 #include "net/base/net_errors.h" | 31 #include "net/base/net_errors.h" |
31 | 32 |
32 // Default timeout interval for connection setup. | 33 // Default timeout interval for connection setup. |
33 // Used if not otherwise specified at ConnectInfo::timeout. | 34 // Used if not otherwise specified at ConnectInfo::timeout. |
34 const int kDefaultConnectTimeoutMillis = 5000; // 5 seconds. | 35 const int kDefaultConnectTimeoutMillis = 5000; // 5 seconds. |
35 | 36 |
36 namespace extensions { | 37 namespace extensions { |
37 | 38 |
38 namespace Close = cast_channel::Close; | 39 namespace Close = cast_channel::Close; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 if (last_errors.net_return_value <= 0) | 95 if (last_errors.net_return_value <= 0) |
95 error_info->net_return_value.reset(new int(last_errors.net_return_value)); | 96 error_info->net_return_value.reset(new int(last_errors.net_return_value)); |
96 } | 97 } |
97 | 98 |
98 bool IsValidConnectInfoPort(const ConnectInfo& connect_info) { | 99 bool IsValidConnectInfoPort(const ConnectInfo& connect_info) { |
99 return connect_info.port > 0 && connect_info.port < | 100 return connect_info.port > 0 && connect_info.port < |
100 std::numeric_limits<uint16_t>::max(); | 101 std::numeric_limits<uint16_t>::max(); |
101 } | 102 } |
102 | 103 |
103 bool IsValidConnectInfoIpAddress(const ConnectInfo& connect_info) { | 104 bool IsValidConnectInfoIpAddress(const ConnectInfo& connect_info) { |
104 net::IPAddressNumber ip_address; | 105 net::IPAddress ip_address; |
105 return net::ParseIPLiteralToNumber(connect_info.ip_address, &ip_address); | 106 return ip_address.AssignFromIPLiteral(connect_info.ip_address); |
106 } | 107 } |
107 | 108 |
108 } // namespace | 109 } // namespace |
109 | 110 |
110 CastChannelAPI::CastChannelAPI(content::BrowserContext* context) | 111 CastChannelAPI::CastChannelAPI(content::BrowserContext* context) |
111 : browser_context_(context), | 112 : browser_context_(context), |
112 logger_(new Logger(make_scoped_ptr<base::Clock>(new base::DefaultClock), | 113 logger_(new Logger(make_scoped_ptr<base::Clock>(new base::DefaultClock), |
113 base::Time::UnixEpoch())) { | 114 base::Time::UnixEpoch())) { |
114 DCHECK(browser_context_); | 115 DCHECK(browser_context_); |
115 } | 116 } |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 std::string& signature = params_->signature; | 562 std::string& signature = params_->signature; |
562 if (signature.empty() || keys.empty() || | 563 if (signature.empty() || keys.empty() || |
563 !cast_channel::SetTrustedCertificateAuthorities(keys, signature)) { | 564 !cast_channel::SetTrustedCertificateAuthorities(keys, signature)) { |
564 SetError("Unable to set authority keys."); | 565 SetError("Unable to set authority keys."); |
565 } | 566 } |
566 | 567 |
567 AsyncWorkCompleted(); | 568 AsyncWorkCompleted(); |
568 } | 569 } |
569 | 570 |
570 } // namespace extensions | 571 } // namespace extensions |
OLD | NEW |