OLD | NEW |
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 // An implementation of BrowserProcess for unit tests that fails for most | 5 // An implementation of BrowserProcess for unit tests that fails for most |
6 // services. By preventing creation of services, we reduce dependencies and | 6 // services. By preventing creation of services, we reduce dependencies and |
7 // keep the profile clean. Clients of this class must handle the NULL return | 7 // keep the profile clean. Clients of this class must handle the NULL return |
8 // value, however. | 8 // value, however. |
9 | 9 |
10 #ifndef CHROME_TEST_BASE_TESTING_BROWSER_PROCESS_H_ | 10 #ifndef CHROME_TEST_BASE_TESTING_BROWSER_PROCESS_H_ |
11 #define CHROME_TEST_BASE_TESTING_BROWSER_PROCESS_H_ | 11 #define CHROME_TEST_BASE_TESTING_BROWSER_PROCESS_H_ |
12 | 12 |
13 #include <string> | 13 #include <string> |
14 | 14 |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
18 #include "chrome/browser/browser_process.h" | 18 #include "chrome/browser/browser_process.h" |
19 | 19 |
20 class BackgroundModeManager; | 20 class BackgroundModeManager; |
21 class CRLSetFetcher; | 21 class CRLSetFetcher; |
22 class IOThread; | 22 class IOThread; |
23 class MHTMLGenerationManager; | 23 class MHTMLGenerationManager; |
24 class NotificationUIManager; | 24 class NotificationUIManager; |
25 class PrefServiceSimple; | 25 class PrefService; |
26 class WatchDogThread; | 26 class WatchDogThread; |
27 | 27 |
28 namespace content { | 28 namespace content { |
29 class NotificationService; | 29 class NotificationService; |
30 } | 30 } |
31 | 31 |
32 namespace policy { | 32 namespace policy { |
33 class BrowserPolicyConnector; | 33 class BrowserPolicyConnector; |
34 class PolicyService; | 34 class PolicyService; |
35 } | 35 } |
36 | 36 |
37 namespace prerender { | 37 namespace prerender { |
38 class PrerenderTracker; | 38 class PrerenderTracker; |
39 } | 39 } |
40 | 40 |
41 class TestingBrowserProcess : public BrowserProcess { | 41 class TestingBrowserProcess : public BrowserProcess { |
42 public: | 42 public: |
43 TestingBrowserProcess(); | 43 TestingBrowserProcess(); |
44 virtual ~TestingBrowserProcess(); | 44 virtual ~TestingBrowserProcess(); |
45 | 45 |
46 // Convenience method to get g_browser_process as a TestingBrowserProcess*. | 46 // Convenience method to get g_browser_process as a TestingBrowserProcess*. |
47 static TestingBrowserProcess* GetGlobal(); | 47 static TestingBrowserProcess* GetGlobal(); |
48 | 48 |
49 virtual void ResourceDispatcherHostCreated() OVERRIDE; | 49 virtual void ResourceDispatcherHostCreated() OVERRIDE; |
50 virtual void EndSession() OVERRIDE; | 50 virtual void EndSession() OVERRIDE; |
51 virtual MetricsService* metrics_service() OVERRIDE; | 51 virtual MetricsService* metrics_service() OVERRIDE; |
52 virtual IOThread* io_thread() OVERRIDE; | 52 virtual IOThread* io_thread() OVERRIDE; |
53 virtual WatchDogThread* watchdog_thread() OVERRIDE; | 53 virtual WatchDogThread* watchdog_thread() OVERRIDE; |
54 virtual ProfileManager* profile_manager() OVERRIDE; | 54 virtual ProfileManager* profile_manager() OVERRIDE; |
55 virtual PrefServiceSimple* local_state() OVERRIDE; | 55 virtual PrefService* local_state() OVERRIDE; |
56 virtual chrome_variations::VariationsService* variations_service() OVERRIDE; | 56 virtual chrome_variations::VariationsService* variations_service() OVERRIDE; |
57 virtual policy::BrowserPolicyConnector* browser_policy_connector() OVERRIDE; | 57 virtual policy::BrowserPolicyConnector* browser_policy_connector() OVERRIDE; |
58 virtual policy::PolicyService* policy_service() OVERRIDE; | 58 virtual policy::PolicyService* policy_service() OVERRIDE; |
59 virtual IconManager* icon_manager() OVERRIDE; | 59 virtual IconManager* icon_manager() OVERRIDE; |
60 virtual GLStringManager* gl_string_manager() OVERRIDE; | 60 virtual GLStringManager* gl_string_manager() OVERRIDE; |
61 virtual RenderWidgetSnapshotTaker* GetRenderWidgetSnapshotTaker() OVERRIDE; | 61 virtual RenderWidgetSnapshotTaker* GetRenderWidgetSnapshotTaker() OVERRIDE; |
62 virtual BackgroundModeManager* background_mode_manager() OVERRIDE; | 62 virtual BackgroundModeManager* background_mode_manager() OVERRIDE; |
63 virtual StatusTray* status_tray() OVERRIDE; | 63 virtual StatusTray* status_tray() OVERRIDE; |
64 virtual SafeBrowsingService* safe_browsing_service() OVERRIDE; | 64 virtual SafeBrowsingService* safe_browsing_service() OVERRIDE; |
65 virtual safe_browsing::ClientSideDetectionService* | 65 virtual safe_browsing::ClientSideDetectionService* |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 virtual ComponentUpdateService* component_updater() OVERRIDE; | 105 virtual ComponentUpdateService* component_updater() OVERRIDE; |
106 virtual CRLSetFetcher* crl_set_fetcher() OVERRIDE; | 106 virtual CRLSetFetcher* crl_set_fetcher() OVERRIDE; |
107 virtual BookmarkPromptController* bookmark_prompt_controller() OVERRIDE; | 107 virtual BookmarkPromptController* bookmark_prompt_controller() OVERRIDE; |
108 virtual chrome::MediaFileSystemRegistry* | 108 virtual chrome::MediaFileSystemRegistry* |
109 media_file_system_registry() OVERRIDE; | 109 media_file_system_registry() OVERRIDE; |
110 virtual void PlatformSpecificCommandLineProcessing( | 110 virtual void PlatformSpecificCommandLineProcessing( |
111 const CommandLine& command_line) OVERRIDE; | 111 const CommandLine& command_line) OVERRIDE; |
112 | 112 |
113 // Set the local state for tests. Consumer is responsible for cleaning it up | 113 // Set the local state for tests. Consumer is responsible for cleaning it up |
114 // afterwards (using ScopedTestingLocalState, for example). | 114 // afterwards (using ScopedTestingLocalState, for example). |
115 void SetLocalState(PrefServiceSimple* local_state); | 115 void SetLocalState(PrefService* local_state); |
116 void SetProfileManager(ProfileManager* profile_manager); | 116 void SetProfileManager(ProfileManager* profile_manager); |
117 void SetIOThread(IOThread* io_thread); | 117 void SetIOThread(IOThread* io_thread); |
118 void SetBrowserPolicyConnector(policy::BrowserPolicyConnector* connector); | 118 void SetBrowserPolicyConnector(policy::BrowserPolicyConnector* connector); |
119 void SetSafeBrowsingService(SafeBrowsingService* sb_service); | 119 void SetSafeBrowsingService(SafeBrowsingService* sb_service); |
120 void SetBookmarkPromptController(BookmarkPromptController* controller); | 120 void SetBookmarkPromptController(BookmarkPromptController* controller); |
121 void SetSystemRequestContext(net::URLRequestContextGetter* context_getter); | 121 void SetSystemRequestContext(net::URLRequestContextGetter* context_getter); |
122 | 122 |
123 private: | 123 private: |
124 scoped_ptr<content::NotificationService> notification_service_; | 124 scoped_ptr<content::NotificationService> notification_service_; |
125 unsigned int module_ref_count_; | 125 unsigned int module_ref_count_; |
(...skipping 15 matching lines...) Expand all Loading... |
141 scoped_refptr<printing::PrintPreviewDialogController> | 141 scoped_refptr<printing::PrintPreviewDialogController> |
142 print_preview_dialog_controller_; | 142 print_preview_dialog_controller_; |
143 scoped_ptr<prerender::PrerenderTracker> prerender_tracker_; | 143 scoped_ptr<prerender::PrerenderTracker> prerender_tracker_; |
144 scoped_ptr<RenderWidgetSnapshotTaker> render_widget_snapshot_taker_; | 144 scoped_ptr<RenderWidgetSnapshotTaker> render_widget_snapshot_taker_; |
145 scoped_refptr<SafeBrowsingService> sb_service_; | 145 scoped_refptr<SafeBrowsingService> sb_service_; |
146 scoped_ptr<BookmarkPromptController> bookmark_prompt_controller_; | 146 scoped_ptr<BookmarkPromptController> bookmark_prompt_controller_; |
147 scoped_ptr<chrome::MediaFileSystemRegistry> media_file_system_registry_; | 147 scoped_ptr<chrome::MediaFileSystemRegistry> media_file_system_registry_; |
148 #endif // !defined(OS_IOS) | 148 #endif // !defined(OS_IOS) |
149 | 149 |
150 // The following objects are not owned by TestingBrowserProcess: | 150 // The following objects are not owned by TestingBrowserProcess: |
151 PrefServiceSimple* local_state_; | 151 PrefService* local_state_; |
152 IOThread* io_thread_; | 152 IOThread* io_thread_; |
153 net::URLRequestContextGetter* system_request_context_; | 153 net::URLRequestContextGetter* system_request_context_; |
154 | 154 |
155 DISALLOW_COPY_AND_ASSIGN(TestingBrowserProcess); | 155 DISALLOW_COPY_AND_ASSIGN(TestingBrowserProcess); |
156 }; | 156 }; |
157 | 157 |
158 #endif // CHROME_TEST_BASE_TESTING_BROWSER_PROCESS_H_ | 158 #endif // CHROME_TEST_BASE_TESTING_BROWSER_PROCESS_H_ |
OLD | NEW |