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.
5 // Library functions related to the Financial Server ping.
7 #ifndef RLZ_LIB_FINANCIAL_PING_H_
8 #define RLZ_LIB_FINANCIAL_PING_H_
11 #include "rlz/lib/rlz_enums.h"
13 #if defined(RLZ_NETWORK_IMPLEMENTATION_CHROME_NET)
15 class URLRequestContextGetter
;
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
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
);
61 #if defined(RLZ_NETWORK_IMPLEMENTATION_CHROME_NET)
63 void ResetSendFinancialPingInterrupted();
64 bool WasSendFinancialPingInterrupted();
68 } // namespace rlz_lib
71 #endif // RLZ_LIB_FINANCIAL_PING_H_