| OLD | NEW |
| (Empty) |
| 1 // Copyright 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/common/extensions/api/diagnostics.h" | |
| 12 #include "extensions/browser/api/async_api_function.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 { | |
| 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 ~DiagnosticsSendPacketFunction() override; | |
| 38 | |
| 39 // AsyncApiFunction: | |
| 40 bool Prepare() override; | |
| 41 // This methods will be implemented differently on different platforms. | |
| 42 void AsyncWorkStart() override; | |
| 43 bool Respond() override; | |
| 44 | |
| 45 private: | |
| 46 void SendPingPacket(); | |
| 47 void OnCompleted(SendPacketResultCode result_code, | |
| 48 const std::string& ip, | |
| 49 double latency); | |
| 50 | |
| 51 scoped_ptr<extensions::api::diagnostics::SendPacket::Params> | |
| 52 parameters_; | |
| 53 }; | |
| 54 | |
| 55 } // namespace extensions | |
| 56 | |
| 57 #endif // CHROME_BROWSER_EXTENSIONS_API_DIAGNOSTICS_DIAGNOSTICS_API_H_ | |
| OLD | NEW |