rlz.h revision c407dc5cd9bdc5668497f21b26b09d988ab439de
1// Copyright (c) 2010 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#ifndef CHROME_BROWSER_RLZ_RLZ_H_ 6#define CHROME_BROWSER_RLZ_RLZ_H_ 7 8#include "build/build_config.h" 9 10#if defined(OS_WIN) 11 12#include <string> 13 14#include "base/basictypes.h" 15#include "rlz/win/lib/rlz_lib.h" 16 17// RLZ is a library which is used to measure distribution scenarios. 18// Its job is to record certain lifetime events in the registry and to send 19// them encoded as a compact string at most twice. The sent data does 20// not contain information that can be used to identify a user or to infer 21// browsing habits. The API in this file is a wrapper around the open source 22// RLZ library which can be found at http://code.google.com/p/rlz. 23// 24// For partner or bundled installs, the RLZ might send more information 25// according to the terms disclosed in the EULA. 26 27class RLZTracker { 28 29 public: 30 // Like InitRlz() this function initializes the RLZ library services for use 31 // in chrome. Besides binding the dll, it schedules a delayed task (delayed 32 // by |delay| seconds) that performs the ping and registers some events 33 // when 'first-run' is true. 34 // 35 // If the chrome brand is organic (no partners) then the RLZ library is not 36 // loaded or initialized and the pings don't ocurr. 37 static bool InitRlzDelayed(bool first_run, int delay); 38 39 // Records an RLZ event. Some events can be access point independent. 40 // Returns false it the event could not be recorded. Requires write access 41 // to the HKCU registry hive on windows. 42 static bool RecordProductEvent(rlz_lib::Product product, 43 rlz_lib::AccessPoint point, 44 rlz_lib::Event event_id); 45 46 // Get the RLZ value of the access point. 47 // Returns false if the rlz string could not be obtained. In some cases 48 // an empty string can be returned which is not an error. 49 static bool GetAccessPointRlz(rlz_lib::AccessPoint point, std::wstring* rlz); 50 51 // Clear all events reported by this product. In Chrome this will be called 52 // when it is un-installed. 53 static bool ClearAllProductEvents(rlz_lib::Product product); 54 55 // Invoked during shutdown to clean up any state created by RLZTracker. 56 static void CleanupRlz(); 57 58 private: 59 DISALLOW_IMPLICIT_CONSTRUCTORS(RLZTracker); 60}; 61 62#endif // defined(OS_WIN) 63 64#endif // CHROME_BROWSER_RLZ_RLZ_H_ 65