Chromium Code Reviews| Index: chrome/browser/extensions/api/diagnostics/diagnostics_api.h |
| diff --git a/chrome/browser/extensions/api/diagnostics/diagnostics_api.h b/chrome/browser/extensions/api/diagnostics/diagnostics_api.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..00accf1dca0dfe77a16abe840a411b17a78f052b |
| --- /dev/null |
| +++ b/chrome/browser/extensions/api/diagnostics/diagnostics_api.h |
| @@ -0,0 +1,56 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_EXTENSIONS_API_DIAGNOSTICS_DIAGNOSTICS_API_H_ |
| +#define CHROME_BROWSER_EXTENSIONS_API_DIAGNOSTICS_DIAGNOSTICS_API_H_ |
| + |
| +#include <string> |
| + |
| +#include "base/memory/scoped_ptr.h" |
| +#include "chrome/browser/extensions/api/api_function.h" |
| +#include "chrome/common/extensions/api/diagnostics.h" |
| + |
| +namespace extensions { |
| + |
| +class DiagnosticsSendPacketFunction : public AsyncApiFunction { |
| + public: |
| + // Result code for sending packet. Platform specific AsyncWorkStart() will |
| + // finish with this ResultCode so we can maximize shared code. |
| + 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
|
| + // Ping packed is sent and ICMP reply is received before time out. |
| + SEND_PACKET_OK, |
| + |
| + // Not implemented on the platform. |
| + SEND_PACKET_NOT_IMPLEMENTED, |
| + |
| + // The ping operation failed because of timeout or network unreachable. |
| + SEND_PACKET_FAILED, |
| + }; |
| + |
| + DECLARE_EXTENSION_FUNCTION("diagnostics.sendPacket", |
| + DIAGNOSTICS_SENDPACKET); |
| + |
| + DiagnosticsSendPacketFunction(); |
| + |
| + protected: |
| + virtual ~DiagnosticsSendPacketFunction(); |
| + |
| + // AsyncApiFunction: |
| + virtual bool Prepare() OVERRIDE; |
| + 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.
|
| + virtual bool Respond() OVERRIDE; |
| + |
| + private: |
| + void SendPingPacket(); |
| + void OnCompleted(SendPacketResultCode result_code, |
| + const std::string& ip, |
| + double latency); |
| + |
| + scoped_ptr<extensions::api::diagnostics::SendPacket::Params> |
| + parameters_; |
| +}; |
| + |
| +} // namespace extensions |
| + |
| +#endif // CHROME_BROWSER_EXTENSIONS_API_DIAGNOSTICS_DIAGNOSTICS_API_H_ |