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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698