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

Side by Side Diff: chrome/browser/extensions/api/diagnostics/diagnostics_api.cc

Issue 17210002: Connectivity Diagnostics API: chrome.diagnostics.sendPacket (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixes 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 "chrome/browser/extensions/api/diagnostics/diagnostics_api.h"
6
7 #include "chrome/browser/extensions/api/diagnostics/send_ping_packet.h"
8
9 namespace SendPacket = extensions::api::diagnostics::SendPacket;
10
11 using base::Callback;
not at google - send to devlin 2013/06/20 23:32:12 not used
Bei Zhang 2013/06/21 08:31:07 Done.
12
13 namespace {
14
15 const char kErrorPingNotImplemented[] = "Not implemented.";
16 const char kErrorPingFailed[] = "Failed to send ping packet.";
17
18 }
19
20 namespace extensions {
21
22 DiagnosticsSendPacketFunction::DiagnosticsSendPacketFunction() {}
23
24 DiagnosticsSendPacketFunction::~DiagnosticsSendPacketFunction() {}
25
26 bool DiagnosticsSendPacketFunction::Prepare() {
27 parameters_ = SendPacket::Params::Create(*args_);
28 EXTENSION_FUNCTION_VALIDATE(parameters_.get());
29 return true;
30 }
31
32 void DiagnosticsSendPacketFunction::AsyncWorkStart() {
33 extensions::SendPingPacket(
34 parameters_->options.ip,
35 parameters_->options.ttl.get(),
36 parameters_->options.timeout.get(),
37 parameters_->options.size.get(),
not at google - send to devlin 2013/06/20 23:32:12 maybe you can just pass parameters->options() into
Bei Zhang 2013/06/21 08:31:07 Done.
38 base::Bind(&DiagnosticsSendPacketFunction::OnComplete, this));
39 }
40
41 bool DiagnosticsSendPacketFunction::Respond() {
42 return error_.empty();
43 }
44
45 void DiagnosticsSendPacketFunction::OnComplete(
46 SendPingPacketResultCode result_code,
47 const std::string& ip,
48 double latency) {
49
not at google - send to devlin 2013/06/20 23:32:12 no blank line
Bei Zhang 2013/06/21 08:31:07 Done.
50 switch (result_code) {
51 case extensions::SEND_PING_PACKET_OK: {
52 extensions::api::diagnostics::SendPacketResult result;
not at google - send to devlin 2013/06/20 23:32:12 extensions:: unnecessary also, decide whether to
Bei Zhang 2013/06/21 08:31:07 Done.
53 result.ip = ip;
54 result.latency = latency;
55 SetResult(result.ToValue().release());
not at google - send to devlin 2013/06/20 23:32:12 IIRC the "results" are actually a list, the argume
Bei Zhang 2013/06/21 08:31:07 SetResult creates a new ListValue and appends the
not at google - send to devlin 2013/06/21 17:13:24 Ah I see. Right. What I'm thinking of is SendPacke
Bei Zhang 2013/06/21 19:31:44 Yeah that makes sense. Done. On 2013/06/21 17:13:
56 break;
57 }
58 case extensions::SEND_PING_PACKET_NOT_IMPLEMENTED:
59 SetError(kErrorPingNotImplemented);
60 break;
61 case extensions::SEND_PING_PACKET_FAILED:
62 SetError(kErrorPingFailed);
63 break;
64 }
65 AsyncWorkCompleted();
66 }
67
68 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698