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

Side by Side Diff: chrome/browser/instant/instant_service.h

Issue 12386019: Instant: Use only one hidden WebContents per profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_INSTANT_INSTANT_SERVICE_H_ 5 #ifndef CHROME_BROWSER_INSTANT_INSTANT_SERVICE_H_
6 #define CHROME_BROWSER_INSTANT_INSTANT_SERVICE_H_ 6 #define CHROME_BROWSER_INSTANT_INSTANT_SERVICE_H_
7 7
8 #include <list>
8 #include <set> 9 #include <set>
10 #include <string>
11 #include <utility>
12 #include <vector>
9 13
10 #include "base/basictypes.h" 14 #include "base/basictypes.h"
11 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
16 #include "base/memory/scoped_ptr.h"
17 #include "base/observer_list.h"
18 #include "base/prefs/public/pref_change_registrar.h"
19 #include "base/string16.h"
20 #include "chrome/browser/history/history_types.h"
12 #include "chrome/browser/profiles/profile_keyed_service.h" 21 #include "chrome/browser/profiles/profile_keyed_service.h"
22 #include "chrome/common/instant_types.h"
13 #include "content/public/browser/notification_observer.h" 23 #include "content/public/browser/notification_observer.h"
14 #include "content/public/browser/notification_registrar.h" 24 #include "content/public/browser/notification_registrar.h"
15 25
16 // Tracks render process host IDs that are associated with Instant. 26 class InstantLoader;
27 class InstantServiceObserver;
28 class Profile;
29 class ThemeService;
30
31 namespace history {
32 class TopSites;
33 }
34
35 // Tracks Instant-related per-profile things, such as render process host IDs,
36 // chrome://settings preferences, omnibox size, theme background, etc.
17 class InstantService : public ProfileKeyedService, 37 class InstantService : public ProfileKeyedService,
18 public content::NotificationObserver { 38 public content::NotificationObserver {
19 public: 39 public:
20 InstantService(); 40 explicit InstantService(Profile* profile);
21 virtual ~InstantService(); 41 virtual ~InstantService();
22 42
23 // Add, remove, and query RenderProcessHost IDs that are associated with 43 Profile* profile() const { return profile_; }
24 // Instant processes. 44 InstantLoader* loader() const { return loader_.get(); }
45
46 const std::list<std::pair<int64, std::string> >& debug_events() const {
47 return debug_events_;
48 }
49 void LogDebugEvent(const std::string& message);
50
51 void AddObserver(InstantServiceObserver* observer);
52 void RemoveObserver(InstantServiceObserver* observer);
53
54 // Add and query RenderProcessHost IDs associated with Instant processes.
25 void AddInstantProcess(int process_id); 55 void AddInstantProcess(int process_id);
26 bool IsInstantProcess(int process_id) const; 56 bool IsInstantProcess(int process_id) const;
27 57
28 #if defined(UNIT_TEST) 58 #if defined(UNIT_TEST)
29 int GetInstantProcessCount() const { 59 int GetInstantProcessCount() const { return process_ids_.size(); }
30 return process_ids_.size();
31 }
32 #endif 60 #endif
33 61
62 const string16& omnibox_font_name() const { return omnibox_font_name_; }
63 size_t omnibox_font_size() const { return omnibox_font_size_; }
64
65 // The omnibox start margin is the same in all browser windows in a profile,
66 // so it can be considered a per-profile setting. It is used in contexts
67 // where there are no browser windows available, such as in InstantLoader.
68 // However, since InstantService has no knowledge of browser windows, this
69 // information must be passed to us by say, an InstantController. If there
70 // are multiple windows open, and the margin changes, each instance of
71 // InstantController will call us with this info, but it shouldn't be a
72 // problem since, as above, the info will be the same in all calls.
73 int omnibox_start_margin() const { return omnibox_start_margin_; }
74 void set_omnibox_start_margin(int omnibox_start_margin) {
75 omnibox_start_margin_ = omnibox_start_margin;
76 }
77
78 const ThemeBackgroundInfo& theme_info() const { return theme_info_; }
79
80 const std::vector<MostVisitedItem>& most_visited_items() const {
81 return most_visited_items_;
82 }
83
84 void InstantSupportDecided();
85
34 private: 86 private:
35 // Overridden from ProfileKeyedService:
36 virtual void Shutdown() OVERRIDE;
37
38 // Overridden from content::NotificationObserver: 87 // Overridden from content::NotificationObserver:
39 virtual void Observe(int type, 88 virtual void Observe(int type,
40 const content::NotificationSource& source, 89 const content::NotificationSource& source,
41 const content::NotificationDetails& details) OVERRIDE; 90 const content::NotificationDetails& details) OVERRIDE;
42 91
43 // The process ids associated with Instant processes. 92 void PrefChanged(const std::string& pref_name);
samarth 2013/03/01 17:59:53 Comments for what these do please.
sreeram 2013/03/07 18:18:46 Done.
93 void ParseTheme(ThemeService* theme_service);
94 void RequestMostVisitedItems(history::TopSites* top_sites);
95 void MostVisitedItemsReceived(const history::MostVisitedURLList& data);
96
97 Profile* const profile_;
98 scoped_ptr<InstantLoader> loader_;
99
100 std::list<std::pair<int64, std::string> > debug_events_;
samarth 2013/03/01 17:59:53 A typedef here (mapping InstantService::DebugMessa
sreeram 2013/03/07 18:18:46 Done.
101
102 ObserverList<InstantServiceObserver> observers_;
103 content::NotificationRegistrar notification_registrar_;
104 PrefChangeRegistrar pref_change_registrar_;
105
106 // The process IDs associated with Instant processes.
44 std::set<int> process_ids_; 107 std::set<int> process_ids_;
45 108
46 content::NotificationRegistrar registrar_; 109 // Omnibox font name and size. Initialized at startup. These never change.
110 string16 omnibox_font_name_;
111 size_t omnibox_font_size_;
112
113 int omnibox_start_margin_;
114
115 bool instant_pref_enabled_;
116 bool instant_enabled_;
117
118 ThemeBackgroundInfo theme_info_;
119
120 std::vector<MostVisitedItem> most_visited_items_;
47 121
48 DISALLOW_COPY_AND_ASSIGN(InstantService); 122 DISALLOW_COPY_AND_ASSIGN(InstantService);
49 }; 123 };
50 124
51 #endif // CHROME_BROWSER_INSTANT_INSTANT_SERVICE_H_ 125 #endif // CHROME_BROWSER_INSTANT_INSTANT_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698