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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/extensions/api/dns/host_resolver_wrapper.h" | 9 #include "chrome/browser/extensions/api/dns/host_resolver_wrapper.h" |
10 #include "chrome/browser/extensions/api/socket/socket.h" | 10 #include "chrome/browser/extensions/api/socket/socket.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 | 35 |
36 SocketAsyncApiFunction::SocketAsyncApiFunction() | 36 SocketAsyncApiFunction::SocketAsyncApiFunction() |
37 : manager_(NULL) { | 37 : manager_(NULL) { |
38 } | 38 } |
39 | 39 |
40 SocketAsyncApiFunction::~SocketAsyncApiFunction() { | 40 SocketAsyncApiFunction::~SocketAsyncApiFunction() { |
41 } | 41 } |
42 | 42 |
43 bool SocketAsyncApiFunction::PrePrepare() { | 43 bool SocketAsyncApiFunction::PrePrepare() { |
44 manager_ = ExtensionSystem::Get(profile())->socket_manager(); | 44 manager_ = ExtensionSystem::Get(profile())->socket_manager(); |
45 DCHECK(manager_) << "There is no socket manager. " | |
46 "If this assertion is failing during a test, then it is likely that " | |
47 "TestExtensionSystem is failing to provide an instance of " | |
48 "ApiResourceManager<Socket>."; | |
49 return manager_ != NULL; | 45 return manager_ != NULL; |
50 } | 46 } |
51 | 47 |
52 bool SocketAsyncApiFunction::Respond() { | 48 bool SocketAsyncApiFunction::Respond() { |
53 return error_.empty(); | 49 return error_.empty(); |
54 } | 50 } |
55 | 51 |
56 SocketExtensionWithDnsLookupFunction::SocketExtensionWithDnsLookupFunction() | 52 SocketExtensionWithDnsLookupFunction::SocketExtensionWithDnsLookupFunction() |
57 : io_thread_(g_browser_process->io_thread()), | 53 : io_thread_(g_browser_process->io_thread()), |
58 request_handle_(new net::HostResolver::RequestHandle), | 54 request_handle_(new net::HostResolver::RequestHandle), |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 bool result = false; | 443 bool result = false; |
448 Socket* socket = manager_->Get(params_->socket_id); | 444 Socket* socket = manager_->Get(params_->socket_id); |
449 if (socket) | 445 if (socket) |
450 result = socket->SetNoDelay(params_->no_delay); | 446 result = socket->SetNoDelay(params_->no_delay); |
451 else | 447 else |
452 error_ = kSocketNotFoundError; | 448 error_ = kSocketNotFoundError; |
453 SetResult(Value::CreateBooleanValue(result)); | 449 SetResult(Value::CreateBooleanValue(result)); |
454 } | 450 } |
455 | 451 |
456 } // namespace extensions | 452 } // namespace extensions |
OLD | NEW |