OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/socket/socket_api.h" | 5 #include "chrome/browser/extensions/api/socket/socket_api.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/extensions/api/dns/host_resolver_wrapper.h" | 12 #include "chrome/browser/extensions/api/dns/host_resolver_wrapper.h" |
13 #include "chrome/browser/extensions/api/socket/socket.h" | 13 #include "chrome/browser/extensions/api/socket/socket.h" |
14 #include "chrome/browser/extensions/api/socket/tcp_socket.h" | 14 #include "chrome/browser/extensions/api/socket/tcp_socket.h" |
15 #include "chrome/browser/extensions/api/socket/udp_socket.h" | 15 #include "chrome/browser/extensions/api/socket/udp_socket.h" |
16 #include "chrome/browser/io_thread.h" | 16 #include "chrome/browser/io_thread.h" |
17 #include "chrome/browser/profiles/profile.h" | |
18 #include "chrome/common/extensions/permissions/socket_permission.h" | 17 #include "chrome/common/extensions/permissions/socket_permission.h" |
19 #include "extensions/browser/extension_system.h" | 18 #include "extensions/browser/extension_system.h" |
20 #include "extensions/common/extension.h" | 19 #include "extensions/common/extension.h" |
21 #include "extensions/common/permissions/permissions_data.h" | 20 #include "extensions/common/permissions/permissions_data.h" |
22 #include "net/base/host_port_pair.h" | 21 #include "net/base/host_port_pair.h" |
23 #include "net/base/io_buffer.h" | 22 #include "net/base/io_buffer.h" |
24 #include "net/base/ip_endpoint.h" | 23 #include "net/base/ip_endpoint.h" |
25 #include "net/base/net_errors.h" | 24 #include "net/base/net_errors.h" |
26 #include "net/base/net_log.h" | 25 #include "net/base/net_log.h" |
27 #include "net/base/net_util.h" | 26 #include "net/base/net_util.h" |
(...skipping 21 matching lines...) Expand all Loading... |
49 const int kWildcardPort = 0; | 48 const int kWildcardPort = 0; |
50 | 49 |
51 SocketAsyncApiFunction::SocketAsyncApiFunction() { | 50 SocketAsyncApiFunction::SocketAsyncApiFunction() { |
52 } | 51 } |
53 | 52 |
54 SocketAsyncApiFunction::~SocketAsyncApiFunction() { | 53 SocketAsyncApiFunction::~SocketAsyncApiFunction() { |
55 } | 54 } |
56 | 55 |
57 bool SocketAsyncApiFunction::PrePrepare() { | 56 bool SocketAsyncApiFunction::PrePrepare() { |
58 manager_ = CreateSocketResourceManager(); | 57 manager_ = CreateSocketResourceManager(); |
59 return manager_->SetProfile(GetProfile()); | 58 return manager_->SetBrowserContext(browser_context()); |
60 } | 59 } |
61 | 60 |
62 bool SocketAsyncApiFunction::Respond() { | 61 bool SocketAsyncApiFunction::Respond() { |
63 return error_.empty(); | 62 return error_.empty(); |
64 } | 63 } |
65 | 64 |
66 scoped_ptr<SocketResourceManagerInterface> | 65 scoped_ptr<SocketResourceManagerInterface> |
67 SocketAsyncApiFunction::CreateSocketResourceManager() { | 66 SocketAsyncApiFunction::CreateSocketResourceManager() { |
68 return scoped_ptr<SocketResourceManagerInterface>( | 67 return scoped_ptr<SocketResourceManagerInterface>( |
69 new SocketResourceManager<Socket>()).Pass(); | 68 new SocketResourceManager<Socket>()).Pass(); |
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
892 return; | 891 return; |
893 } | 892 } |
894 | 893 |
895 base::ListValue* values = new base::ListValue(); | 894 base::ListValue* values = new base::ListValue(); |
896 values->AppendStrings((std::vector<std::string>&) | 895 values->AppendStrings((std::vector<std::string>&) |
897 static_cast<UDPSocket*>(socket)->GetJoinedGroups()); | 896 static_cast<UDPSocket*>(socket)->GetJoinedGroups()); |
898 SetResult(values); | 897 SetResult(values); |
899 } | 898 } |
900 | 899 |
901 } // namespace extensions | 900 } // namespace extensions |
OLD | NEW |