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

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: Fix build 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 namespace SendPacket = extensions::api::diagnostics::SendPacket;
8
9 namespace {
10
11 const char kErrorPingNotImplemented[] = "Not implemented";
12 const char kErrorPingFailed[] = "Failed to send ping packet";
13
14 }
15
16 namespace extensions {
17
18 DiagnosticsSendPacketFunction::DiagnosticsSendPacketFunction() {}
19
20 DiagnosticsSendPacketFunction::~DiagnosticsSendPacketFunction() {}
21
22 bool DiagnosticsSendPacketFunction::Prepare() {
23 parameters_ = SendPacket::Params::Create(*args_);
24 EXTENSION_FUNCTION_VALIDATE(parameters_.get());
25 return true;
26 }
27
28 bool DiagnosticsSendPacketFunction::Respond() {
29 return error_.empty();
30 }
31
32 void DiagnosticsSendPacketFunction::OnCompleted(
33 SendPacketResultCode result_code,
34 const std::string& ip,
35 double latency) {
36 switch (result_code) {
37 case SEND_PACKET_OK: {
38 extensions::api::diagnostics::SendPacketResult result;
39 result.ip = ip;
40 result.latency = latency;
41 results_ = SendPacket::Results::Create(result);
42 break;
43 }
44 case SEND_PACKET_NOT_IMPLEMENTED:
45 SetError(kErrorPingNotImplemented);
46 break;
47 case SEND_PACKET_FAILED:
48 SetError(kErrorPingFailed);
49 break;
50 }
51 AsyncWorkCompleted();
52 }
53
54 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698