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.
5 #ifndef EXTENSIONS_BROWSER_API_DIAGNOSTICS_DIAGNOSTICS_API_H_
6 #define EXTENSIONS_BROWSER_API_DIAGNOSTICS_DIAGNOSTICS_API_H_
10 #include "base/memory/scoped_ptr.h"
11 #include "extensions/browser/api/async_api_function.h"
12 #include "extensions/common/api/diagnostics.h"
14 namespace extensions
{
16 class DiagnosticsSendPacketFunction
: public AsyncApiFunction
{
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.
24 // Not implemented on the platform.
25 SEND_PACKET_NOT_IMPLEMENTED
,
27 // The ping operation failed because of timeout or network unreachable.
31 DECLARE_EXTENSION_FUNCTION("diagnostics.sendPacket", DIAGNOSTICS_SENDPACKET
);
33 DiagnosticsSendPacketFunction();
36 ~DiagnosticsSendPacketFunction() override
;
39 bool Prepare() override
;
40 // This methods will be implemented differently on different platforms.
41 void AsyncWorkStart() override
;
42 bool Respond() override
;
45 void SendPingPacket();
46 void OnCompleted(SendPacketResultCode result_code
,
47 const std::string
& ip
,
50 scoped_ptr
<api::diagnostics::SendPacket::Params
> parameters_
;
53 } // namespace extensions
55 #endif // EXTENSIONS_BROWSER_API_DIAGNOSTICS_DIAGNOSTICS_API_H_