Add ICU message format support
[chromium-blink-merge.git] / extensions / browser / api / diagnostics / diagnostics_api.h
blobcf7ce6c13c2f21c103359b3ac8fbedef06c9f9dd
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_
8 #include <string>
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 {
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,
24 // Not implemented on the platform.
25 SEND_PACKET_NOT_IMPLEMENTED,
27 // The ping operation failed because of timeout or network unreachable.
28 SEND_PACKET_FAILED,
31 DECLARE_EXTENSION_FUNCTION("diagnostics.sendPacket", DIAGNOSTICS_SENDPACKET);
33 DiagnosticsSendPacketFunction();
35 protected:
36 ~DiagnosticsSendPacketFunction() override;
38 // AsyncApiFunction:
39 bool Prepare() override;
40 // This methods will be implemented differently on different platforms.
41 void AsyncWorkStart() override;
42 bool Respond() override;
44 private:
45 void SendPingPacket();
46 void OnCompleted(SendPacketResultCode result_code,
47 const std::string& ip,
48 double latency);
50 scoped_ptr<api::diagnostics::SendPacket::Params> parameters_;
53 } // namespace extensions
55 #endif // EXTENSIONS_BROWSER_API_DIAGNOSTICS_DIAGNOSTICS_API_H_