Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 #ifndef CHROME_BROWSER_EXTENSIONS_API_DIAGNOSTICS_DIAGNOSTICS_API_H_ | |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_DIAGNOSTICS_DIAGNOSTICS_API_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/memory/scoped_ptr.h" | |
| 11 #include "chrome/browser/extensions/api/api_function.h" | |
| 12 #include "chrome/common/extensions/api/diagnostics.h" | |
| 13 | |
| 14 namespace extensions { | |
| 15 | |
| 16 class DiagnosticsSendPacketFunction : public AsyncApiFunction { | |
| 17 public: | |
| 18 // Result code for sending packet. Platform specific AsyncWorkStart() will | |
| 19 // finish with this ResultCode so we can maximize shared code. | |
| 20 enum SendPacketResultCode { | |
|
not at google - send to devlin
2013/06/21 17:13:24
is this only used internally? if so it can be priv
Bei Zhang
2013/06/21 19:31:44
A static function in diagnostics_api_chromeos.cc i
| |
| 21 // Ping packed is sent and ICMP reply is received before time out. | |
| 22 SEND_PACKET_OK, | |
| 23 | |
| 24 // Not implemented on the platform. | |
| 25 SEND_PACKET_NOT_IMPLEMENTED, | |
| 26 | |
| 27 // The ping operation failed because of timeout or network unreachable. | |
| 28 SEND_PACKET_FAILED, | |
| 29 }; | |
| 30 | |
| 31 DECLARE_EXTENSION_FUNCTION("diagnostics.sendPacket", | |
| 32 DIAGNOSTICS_SENDPACKET); | |
| 33 | |
| 34 DiagnosticsSendPacketFunction(); | |
| 35 | |
| 36 protected: | |
| 37 virtual ~DiagnosticsSendPacketFunction(); | |
| 38 | |
| 39 // AsyncApiFunction: | |
| 40 virtual bool Prepare() OVERRIDE; | |
| 41 virtual void AsyncWorkStart() OVERRIDE; | |
|
not at google - send to devlin
2013/06/21 17:13:24
comment here that this is implemented differently
Bei Zhang
2013/06/21 19:31:44
Done.
| |
| 42 virtual bool Respond() OVERRIDE; | |
| 43 | |
| 44 private: | |
| 45 void SendPingPacket(); | |
| 46 void OnCompleted(SendPacketResultCode result_code, | |
| 47 const std::string& ip, | |
| 48 double latency); | |
| 49 | |
| 50 scoped_ptr<extensions::api::diagnostics::SendPacket::Params> | |
| 51 parameters_; | |
| 52 }; | |
| 53 | |
| 54 } // namespace extensions | |
| 55 | |
| 56 #endif // CHROME_BROWSER_EXTENSIONS_API_DIAGNOSTICS_DIAGNOSTICS_API_H_ | |
| OLD | NEW |