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

Side by Side Diff: chrome/browser/web_resource/promo_resource_service.h

Issue 10690096: Extracted inner class doing process dispatch. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: FIxing initialization bug. Created 8 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_WEB_RESOURCE_PROMO_RESOURCE_SERVICE_H_ 5 #ifndef CHROME_BROWSER_WEB_RESOURCE_PROMO_RESOURCE_SERVICE_H_
6 #define CHROME_BROWSER_WEB_RESOURCE_PROMO_RESOURCE_SERVICE_H_ 6 #define CHROME_BROWSER_WEB_RESOURCE_PROMO_RESOURCE_SERVICE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 16 matching lines...) Expand all
27 public: 27 public:
28 // Checks for conditions to show promo. 28 // Checks for conditions to show promo.
29 static bool CanShowNotificationPromo(Profile* profile); 29 static bool CanShowNotificationPromo(Profile* profile);
30 30
31 static void RegisterPrefs(PrefService* local_state); 31 static void RegisterPrefs(PrefService* local_state);
32 32
33 static void RegisterUserPrefs(PrefService* prefs); 33 static void RegisterUserPrefs(PrefService* prefs);
34 34
35 explicit PromoResourceService(Profile* profile); 35 explicit PromoResourceService(Profile* profile);
36 36
37 // JSONAsynchronousUnpackerDelegate methods.
38 virtual void OnUnpackFinished(const DictionaryValue& parsed_json) OVERRIDE;
39 virtual void OnUnpackError(const std::string& error_message) OVERRIDE;
40
37 private: 41 private:
38 virtual ~PromoResourceService(); 42 virtual ~PromoResourceService();
39 43
40 int GetPromoServiceVersion(); 44 int GetPromoServiceVersion();
41 45
42 // Gets the locale of the last promos fetched from the server. This is saved 46 // Gets the locale of the last promos fetched from the server. This is saved
43 // so we can fetch new data if the locale changes. 47 // so we can fetch new data if the locale changes.
44 std::string GetPromoLocale(); 48 std::string GetPromoLocale();
45 49
46 // Schedule a notification that a web resource is either going to become 50 // Schedule a notification that a web resource is either going to become
47 // available or be no longer valid. 51 // available or be no longer valid.
48 void ScheduleNotification(double start, double end); 52 void ScheduleNotification(double start, double end);
49 53
50 // Schedules the initial notification for when the web resource is going 54 // Schedules the initial notification for when the web resource is going
51 // to become available or no longer valid. This performs a few additional 55 // to become available or no longer valid. This performs a few additional
52 // checks than ScheduleNotification, namely it schedules updates immediately 56 // checks than ScheduleNotification, namely it schedules updates immediately
53 // if the promo service or Chrome locale has changed. 57 // if the promo service or Chrome locale has changed.
54 void ScheduleNotificationOnInit(); 58 void ScheduleNotificationOnInit();
55 59
56 // If delay_ms is positive, schedule notification with the delay. 60 // If delay_ms is positive, schedule notification with the delay.
57 // If delay_ms is 0, notify immediately by calling WebResourceStateChange(). 61 // If delay_ms is 0, notify immediately by calling WebResourceStateChange().
58 // If delay_ms is negative, do nothing. 62 // If delay_ms is negative, do nothing.
59 void PostNotification(int64 delay_ms); 63 void PostNotification(int64 delay_ms);
60 64
61 // Notify listeners that the state of a web resource has changed. 65 // Notify listeners that the state of a web resource has changed.
62 void PromoResourceStateChange(); 66 void PromoResourceStateChange();
63 67
64 // WebResourceService override. 68 // Internal method to process the parsed information.
65 virtual void Unpack(const base::DictionaryValue& parsed_json) OVERRIDE; 69 void Unpack(const base::DictionaryValue& parsed_json);
66 70
67 // The profile this service belongs to. 71 // The profile this service belongs to.
68 Profile* profile_; 72 Profile* profile_;
69 73
70 // Allows the creation of tasks to send a notification. 74 // Allows the creation of tasks to send a notification.
71 // This allows the PromoResourceService to notify the New Tab Page immediately 75 // This allows the PromoResourceService to notify the New Tab Page immediately
72 // when a new web resource should be shown or removed. 76 // when a new web resource should be shown or removed.
73 base::WeakPtrFactory<PromoResourceService> weak_ptr_factory_; 77 base::WeakPtrFactory<PromoResourceService> weak_ptr_factory_;
74 78
75 // Notification type when an update is done. 79 // Notification type when an update is done.
76 int notification_type_; 80 int notification_type_;
77 81
78 // True if a task has been set to update the cache when a new web resource 82 // True if a task has been set to update the cache when a new web resource
79 // becomes available. 83 // becomes available.
80 bool web_resource_update_scheduled_; 84 bool web_resource_update_scheduled_;
81 85
82 DISALLOW_COPY_AND_ASSIGN(PromoResourceService); 86 DISALLOW_COPY_AND_ASSIGN(PromoResourceService);
83 }; 87 };
84 88
85 #endif // CHROME_BROWSER_WEB_RESOURCE_PROMO_RESOURCE_SERVICE_H_ 89 #endif // CHROME_BROWSER_WEB_RESOURCE_PROMO_RESOURCE_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698