Chromium Code Reviews| 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 "It is likely you are testing this API in an isolated environment."; | |
|
asargent_no_longer_on_chrome
2012/07/23 16:57:57
nit: I think this second line of error output is p
| |
| 45 return manager_ != NULL; | 47 return manager_ != NULL; |
| 46 } | 48 } |
| 47 | 49 |
| 48 bool SocketAsyncApiFunction::Respond() { | 50 bool SocketAsyncApiFunction::Respond() { |
| 49 return error_.empty(); | 51 return error_.empty(); |
| 50 } | 52 } |
| 51 | 53 |
| 52 SocketExtensionWithDnsLookupFunction::SocketExtensionWithDnsLookupFunction() | 54 SocketExtensionWithDnsLookupFunction::SocketExtensionWithDnsLookupFunction() |
| 53 : io_thread_(g_browser_process->io_thread()), | 55 : io_thread_(g_browser_process->io_thread()), |
| 54 request_handle_(new net::HostResolver::RequestHandle), | 56 request_handle_(new net::HostResolver::RequestHandle), |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 440 bool result = false; | 442 bool result = false; |
| 441 Socket* socket = manager_->Get(params_->socket_id); | 443 Socket* socket = manager_->Get(params_->socket_id); |
| 442 if (socket) | 444 if (socket) |
| 443 result = socket->SetNoDelay(params_->no_delay); | 445 result = socket->SetNoDelay(params_->no_delay); |
| 444 else | 446 else |
| 445 error_ = kSocketNotFoundError; | 447 error_ = kSocketNotFoundError; |
| 446 SetResult(Value::CreateBooleanValue(result)); | 448 SetResult(Value::CreateBooleanValue(result)); |
| 447 } | 449 } |
| 448 | 450 |
| 449 } // namespace extensions | 451 } // namespace extensions |
| OLD | NEW |