Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "diagnostics_private_api.h" | |
| 6 | |
| 7 #include "chrome/browser/extensions/api/diagnostics_private/send_ping_packet.h" | |
| 8 | |
| 9 namespace SendPacket = extensions::api::diagnostics_private::SendPacket; | |
| 10 | |
| 11 using base::Callback; | |
| 12 | |
| 13 namespace extensions { | |
| 14 | |
| 15 DiagnosticsPrivateSendPacketFunction::DiagnosticsPrivateSendPacketFunction() {} | |
| 16 | |
| 17 DiagnosticsPrivateSendPacketFunction::~DiagnosticsPrivateSendPacketFunction() {} | |
| 18 | |
| 19 bool DiagnosticsPrivateSendPacketFunction::Prepare() { | |
| 20 parameters_ = SendPacket::Params::Create(*args_); | |
| 21 EXTENSION_FUNCTION_VALIDATE(parameters_.get()); | |
| 22 return true; | |
| 23 } | |
| 24 | |
| 25 void DiagnosticsPrivateSendPacketFunction::AsyncWorkStart() { | |
| 26 SendPingPacket( | |
|
stevenjb
2013/06/18 19:19:28
qualify this with extensions:: to make it clear th
Bei Zhang
2013/06/18 22:04:46
Done.
| |
| 27 parameters_->options.ip, | |
| 28 parameters_->options.ttl.get(), | |
| 29 parameters_->options.timeout.get(), | |
| 30 parameters_->options.size.get(), | |
| 31 base::Bind(&DiagnosticsPrivateSendPacketFunction::OnComplete, this)); | |
| 32 } | |
| 33 | |
| 34 bool DiagnosticsPrivateSendPacketFunction::Respond() { | |
| 35 return error_.empty(); | |
| 36 } | |
| 37 | |
| 38 void DiagnosticsPrivateSendPacketFunction::OnComplete( | |
| 39 const std::string& error, | |
| 40 const std::string& ip, | |
| 41 double latency) { | |
| 42 if (error.empty()) { | |
| 43 extensions::api::diagnostics_private::SendPacketResult result; | |
| 44 result.ip = ip; | |
| 45 result.latency = latency; | |
| 46 SetResult(result.ToValue().release()); | |
| 47 } else { | |
| 48 SetError(error); | |
| 49 } | |
| 50 AsyncWorkCompleted(); | |
| 51 } | |
| 52 | |
| 53 } // namespace extensions | |
| OLD | NEW |