Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(303)

Unified Diff: chrome/browser/extensions/api/diagnostics_private/diagnostics_private_api.cc

Issue 17210002: Connectivity Diagnostics API: chrome.diagnostics.sendPacket (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Change the name to diagnosticsPrivate Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/diagnostics_private/diagnostics_private_api.cc
diff --git a/chrome/browser/extensions/api/diagnostics_private/diagnostics_private_api.cc b/chrome/browser/extensions/api/diagnostics_private/diagnostics_private_api.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f6bb66934614b00aa28f96ce38bc7da3ea4d13ba
--- /dev/null
+++ b/chrome/browser/extensions/api/diagnostics_private/diagnostics_private_api.cc
@@ -0,0 +1,53 @@
+// 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 "diagnostics_private_api.h"
+
+#include "chrome/browser/extensions/api/diagnostics_private/send_ping_packet.h"
+
+namespace SendPacket = extensions::api::diagnostics_private::SendPacket;
+
+using base::Callback;
+
+namespace extensions {
+
+DiagnosticsPrivateSendPacketFunction::DiagnosticsPrivateSendPacketFunction() {}
+
+DiagnosticsPrivateSendPacketFunction::~DiagnosticsPrivateSendPacketFunction() {}
+
+bool DiagnosticsPrivateSendPacketFunction::Prepare() {
+ parameters_ = SendPacket::Params::Create(*args_);
+ EXTENSION_FUNCTION_VALIDATE(parameters_.get());
+ return true;
+}
+
+void DiagnosticsPrivateSendPacketFunction::AsyncWorkStart() {
+ 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.
+ parameters_->options.ip,
+ parameters_->options.ttl.get(),
+ parameters_->options.timeout.get(),
+ parameters_->options.size.get(),
+ base::Bind(&DiagnosticsPrivateSendPacketFunction::OnComplete, this));
+}
+
+bool DiagnosticsPrivateSendPacketFunction::Respond() {
+ return error_.empty();
+}
+
+void DiagnosticsPrivateSendPacketFunction::OnComplete(
+ const std::string& error,
+ const std::string& ip,
+ double latency) {
+ if (error.empty()) {
+ extensions::api::diagnostics_private::SendPacketResult result;
+ result.ip = ip;
+ result.latency = latency;
+ SetResult(result.ToValue().release());
+ } else {
+ SetError(error);
+ }
+ AsyncWorkCompleted();
+}
+
+} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698