Remove deprecated extension notification and
[chromium-blink-merge.git] / rlz / lib / financial_ping.h
blob63c20a1f0c89d879d729405bf43c979a9b3bff8e
1 // Copyright (c) 2012 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 // Library functions related to the Financial Server ping.
7 #ifndef RLZ_LIB_FINANCIAL_PING_H_
8 #define RLZ_LIB_FINANCIAL_PING_H_
10 #include <string>
11 #include "rlz/lib/rlz_enums.h"
13 #if defined(RLZ_NETWORK_IMPLEMENTATION_CHROME_NET)
14 namespace net {
15 class URLRequestContextGetter;
16 } // namespace net
17 #endif
19 namespace rlz_lib {
21 class FinancialPing {
22 public:
23 // Form the HTTP request to send to the PSO server.
24 // Will look something like:
25 // /pso/ping?as=swg&brand=GGLD&id=124&hl=en&
26 // events=I7S&rep=1&rlz=I7:val,W1:&dcc=dval
27 static bool FormRequest(Product product, const AccessPoint* access_points,
28 const char* product_signature,
29 const char* product_brand, const char* product_id,
30 const char* product_lang, bool exclude_machine_id,
31 std::string* request);
33 // Returns whether the time is right to send a ping.
34 // If no_delay is true, this should always ping if there are events,
35 // or one week has passed since last_ping when there are no new events.
36 // If no_delay is false, this should ping if current time < last_ping time
37 // (case of time reset) or if one day has passed since last_ping and there
38 // are events, or one week has passed since last_ping when there are
39 // no new events.
40 static bool IsPingTime(Product product, bool no_delay);
42 // Set the last ping time to be now. Writes to RlzValueStore.
43 static bool UpdateLastPingTime(Product product);
45 // Clear the last ping time - should be called on uninstall.
46 // Writes to RlzValueStore.
47 static bool ClearLastPingTime(Product product);
49 // Ping the financial server with request. Writes to RlzValueStore.
50 static bool PingServer(const char* request, std::string* response);
52 #if defined(RLZ_NETWORK_IMPLEMENTATION_CHROME_NET)
53 static bool SetURLRequestContext(net::URLRequestContextGetter* context);
54 #endif
56 private:
57 FinancialPing() {}
58 ~FinancialPing() {}
61 #if defined(RLZ_NETWORK_IMPLEMENTATION_CHROME_NET)
62 namespace test {
63 void ResetSendFinancialPingInterrupted();
64 bool WasSendFinancialPingInterrupted();
65 } // namespace test
66 #endif
68 } // namespace rlz_lib
71 #endif // RLZ_LIB_FINANCIAL_PING_H_