| Index: chrome/browser/extensions/api/ping_private/ping_private_api.cc
|
| diff --git a/chrome/browser/extensions/api/ping_private/ping_private_api.cc b/chrome/browser/extensions/api/ping_private/ping_private_api.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..1b973d5aee79162b7a5ec82a3704fbacda8c036a
|
| --- /dev/null
|
| +++ b/chrome/browser/extensions/api/ping_private/ping_private_api.cc
|
| @@ -0,0 +1,55 @@
|
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "ping_private_api.h"
|
| +
|
| +#include "base/values.h"
|
| +
|
| +#if defined(OS_CHROMEOS)
|
| +#include "chromeos/dbus/icmp_packet_sender.h"
|
| +#endif // defined(OS_CHROMEOS)
|
| +
|
| +namespace SendPacket = extensions::api::ping_private::SendPacket;
|
| +
|
| +namespace extensions {
|
| +
|
| +PingPrivateSendPacketFunction::PingPrivateSendPacketFunction() {}
|
| +
|
| +PingPrivateSendPacketFunction::~PingPrivateSendPacketFunction() {}
|
| +
|
| +bool PingPrivateSendPacketFunction::Prepare() {
|
| + parameters_ = SendPacket::Params::Create(*args_);
|
| + EXTENSION_FUNCTION_VALIDATE(parameters_.get());
|
| + return true;
|
| +}
|
| +
|
| +void PingPrivateSendPacketFunction::AsyncWorkStart() {
|
| +#if defined(OS_CHROMEOS)
|
| + chromeos::ICMPPacketSender::GetInstance()->Send(
|
| + parameters_->options.ip,
|
| + parameters_->options.ttl.get(),
|
| + parameters_->options.timeout.get(),
|
| + parameters_->options.size.get(),
|
| + base::Bind(&PingPrivateSendPacketFunction::OnComplete, this));
|
| +#else
|
| + SetError("Not implemented");
|
| + AsyncWorkCompleted();
|
| +#endif
|
| +}
|
| +
|
| +bool PingPrivateSendPacketFunction::Respond() {
|
| + return error_.empty();
|
| +}
|
| +
|
| +void PingPrivateSendPacketFunction::OnComplete(bool suceeded,
|
| + const std::string& ip,
|
| + int latency) {
|
| + extensions::api::ping_private::SendPacketResult result;
|
| + result.ip = ip;
|
| + result.latency = latency;
|
| + SetResult(result.ToValue().release());
|
| + AsyncWorkCompleted();
|
| +}
|
| +
|
| +} // namespace extensions
|
|
|