| 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>."; |
| 45 return manager_ != NULL; | 49 return manager_ != NULL; |
| 46 } | 50 } |
| 47 | 51 |
| 48 bool SocketAsyncApiFunction::Respond() { | 52 bool SocketAsyncApiFunction::Respond() { |
| 49 return error_.empty(); | 53 return error_.empty(); |
| 50 } | 54 } |
| 51 | 55 |
| 52 SocketExtensionWithDnsLookupFunction::SocketExtensionWithDnsLookupFunction() | 56 SocketExtensionWithDnsLookupFunction::SocketExtensionWithDnsLookupFunction() |
| 53 : io_thread_(g_browser_process->io_thread()), | 57 : io_thread_(g_browser_process->io_thread()), |
| 54 request_handle_(new net::HostResolver::RequestHandle), | 58 request_handle_(new net::HostResolver::RequestHandle), |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 bool result = false; | 447 bool result = false; |
| 444 Socket* socket = manager_->Get(params_->socket_id); | 448 Socket* socket = manager_->Get(params_->socket_id); |
| 445 if (socket) | 449 if (socket) |
| 446 result = socket->SetNoDelay(params_->no_delay); | 450 result = socket->SetNoDelay(params_->no_delay); |
| 447 else | 451 else |
| 448 error_ = kSocketNotFoundError; | 452 error_ = kSocketNotFoundError; |
| 449 SetResult(Value::CreateBooleanValue(result)); | 453 SetResult(Value::CreateBooleanValue(result)); |
| 450 } | 454 } |
| 451 | 455 |
| 452 } // namespace extensions | 456 } // namespace extensions |
| OLD | NEW |