Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1795)

Unified Diff: chrome/browser/profile_resetter/automatic_profile_resetter.h

Issue 27030002: Added collecting of data to be fed to the JTL interpreter. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/profile_resetter/automatic_profile_resetter.h
diff --git a/chrome/browser/profile_resetter/automatic_profile_resetter.h b/chrome/browser/profile_resetter/automatic_profile_resetter.h
index 8dc9176d82c3b6f9915353fcf4c2de61d41b55fa..4772445c87e297831b80bb50b581a26e8f3dc034 100644
--- a/chrome/browser/profile_resetter/automatic_profile_resetter.h
+++ b/chrome/browser/profile_resetter/automatic_profile_resetter.h
@@ -15,23 +15,9 @@
#include "chrome/browser/profile_resetter/automatic_profile_resetter_mementos.h"
#include "components/browser_context_keyed_service/browser_context_keyed_service.h"
+class AutomaticProfileResetterDelegate;
class Profile;
-// Defines the interface for the delegate that will actually show the prompt
-// and/or report statistics on behalf of the AutomaticProfileResetter.
-// The primary reason for this separation is to facilitate unit testing.
-class AutomaticProfileResetterDelegate {
- public:
- virtual ~AutomaticProfileResetterDelegate() {}
-
- // Triggers showing the one-time profile settings reset prompt.
- virtual void ShowPrompt() = 0;
-
- // Reports the given metrics through UMA.
- virtual void ReportStatistics(uint32 satisfied_criteria_mask,
- uint32 combined_status_mask) = 0;
-};
-
// This service becomes busy shortly after start-up, and is responsible for
// evaluating if the criteria for showing the one-time profile reset prompt
// are satisfied, and will potentially trigger the prompt, but only a single
@@ -39,20 +25,33 @@ class AutomaticProfileResetterDelegate {
// "mementos"). All methods in this class shall be called on the UI thread.
class AutomaticProfileResetter : public BrowserContextKeyedService {
public:
+ // Number of bits, and maximum value (exclusive) for the mask whose bits
+ // indicate which of reset criteria were satisfied.
+ static const size_t kSatisfiedCriteriaMaskBits;
+ static const uint32 kSatisfiedCriteriaMaskMaximumValue;
+
+ // Number of bits, and maximum value (exclusive) for the mask whose bits
+ // indicate if any of reset criteria were satisfied, and which of the mementos
+ // were already present.
+ static const size_t kCombinedStatusMaskBits;
+ static const uint32 kCombinedStatusMaskMaximumValue;
+
explicit AutomaticProfileResetter(Profile* profile);
virtual ~AutomaticProfileResetter();
- // Initializes the service, and sets up the asynchronous evaluation flow.
- // Called by AutomaticProfileResetterFactory.
- void Initialize();
+ // Fires up the service by unleashing the asynchronous evaluation flow, unless
+ // the service has been already disabled in MaybeInitialize() or there is no
+ // |program_| to run (in which case the service also gets disabled).
+ // Called by the AutomaticProfileResetterFactory.
+ void MaybeActivate();
battre 2013/10/11 15:05:33 nit: I think I would prefer to drop the Maybe here
engedy 2013/10/11 16:42:16 Done.
- // Should be called after Initialize().
+ // Should be called before MaybeActivate().
void SetHashSeedForTesting(const base::StringPiece& hash_seed);
- // Should be called after Initialize().
+ // Should be called before MaybeActivate().
void SetProgramForTesting(const base::StringPiece& program);
- // Should be called after Initialize(). Takes ownership.
+ // Should be called before MaybeActivate(). Takes ownership.
void SetDelegateForTesting(AutomaticProfileResetterDelegate* delegate);
private:
@@ -60,18 +59,28 @@ class AutomaticProfileResetter : public BrowserContextKeyedService {
enum State {
STATE_UNINITIALIZED,
+ STATE_INITIALIZED,
STATE_DISABLED,
+ STATE_WAITING_ON_SERVICES,
STATE_READY,
STATE_WORKING,
STATE_DONE
};
+ // Initializes the service if it is enabled in the field trial. Otherwise,
+ // permanently disables the service and also skips the initialization steps.
+ void MaybeInitialize();
+
// Returns whether or not a dry-run shall be performed.
bool ShouldPerformDryRun() const;
// Returns whether or not a live-run shall be performed.
bool ShouldPerformLiveRun() const;
+ // Called back by |resetter_delegate_| when the template URL service is ready.
+ // Unleashes the asynchronous evaluation flow.
+ void OnTemplateURLServiceBecameReady();
+
// Begins the asynchronous evaluation flow, which will assess whether the
// criteria for showing the reset prompt are met, whether we have already
// shown the prompt, and, in the end, will potentially trigger the prompt.

Powered by Google App Engine
This is Rietveld 408576698