license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 1 | // Copyright (c) 2006-2008 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. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4 | |
| 5 | // This interfaces is for managing the global services of the application. Each |
| 6 | // service is lazily created when requested the first time. The service getters |
| 7 | // will return NULL if the service is not available, so callers must check for |
| 8 | // this condition. |
| 9 | |
| 10 | #ifndef CHROME_BROWSER_BROWSER_PROCESS_H__ |
| 11 | #define CHROME_BROWSER_BROWSER_PROCESS_H__ |
| 12 | |
| 13 | #include <string> |
| 14 | |
| 15 | #include "base/basictypes.h" |
| 16 | #include "base/message_loop.h" |
| 17 | |
| 18 | class AutomationProviderList; |
| 19 | class ClipboardService; |
| 20 | class GoogleURLTracker; |
| 21 | class IconManager; |
| 22 | class MetricsService; |
| 23 | class NotificationService; |
| 24 | class PrefService; |
| 25 | class ProfileManager; |
| 26 | class RenderProcessHost; |
| 27 | class ResourceDispatcherHost; |
| 28 | class DebuggerWrapper; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 29 | class WebAppInstallerService; |
[email protected] | d65cab7a | 2008-08-12 01:25:41 | [diff] [blame] | 30 | class SharedEvent; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 31 | class SuspendController; |
| 32 | |
[email protected] | ab820df | 2008-08-26 05:55:10 | [diff] [blame^] | 33 | namespace base { |
| 34 | class Thread; |
| 35 | } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 36 | namespace sandbox { |
| 37 | class BrokerServices; |
| 38 | } |
| 39 | namespace ChromeViews { |
| 40 | class AcceleratorHandler; |
| 41 | } |
| 42 | namespace printing { |
| 43 | class PrintJobManager; |
| 44 | } |
| 45 | |
| 46 | // NOT THREAD SAFE, call only from the main thread. |
| 47 | // These functions shouldn't return NULL unless otherwise noted. |
| 48 | class BrowserProcess { |
| 49 | public: |
| 50 | BrowserProcess() {} |
| 51 | virtual ~BrowserProcess() {} |
| 52 | |
| 53 | // The browser has 3 memory model configurations. These models have to |
| 54 | // do with how aggressively we release Renderer memory to the OS. |
| 55 | // Low memory releases memory the fastest, High memory releases it the |
| 56 | // slowest. Geek out! |
| 57 | enum MemoryModel { |
| 58 | // Will release as much memory as it can after each tab switch, and also |
| 59 | // after user idle. |
| 60 | LOW_MEMORY_MODEL, |
| 61 | // Will release a little memory after each tab switch and also after |
| 62 | // user idle. |
| 63 | MEDIUM_MEMORY_MODEL, |
| 64 | // Hangs onto every last byte. |
| 65 | HIGH_MEMORY_MODEL |
| 66 | }; |
| 67 | |
| 68 | // Invoked when the user is logging out/shutting down. When logging off we may |
| 69 | // not have enough time to do a normal shutdown. This method is invoked prior |
| 70 | // to normal shutdown and saves any state that must be saved before we are |
| 71 | // continue shutdown. |
| 72 | virtual void EndSession() = 0; |
| 73 | |
| 74 | // Services: any of these getters may return NULL |
| 75 | virtual ResourceDispatcherHost* resource_dispatcher_host() = 0; |
| 76 | |
| 77 | virtual MetricsService* metrics_service() = 0; |
| 78 | virtual ProfileManager* profile_manager() = 0; |
| 79 | virtual PrefService* local_state() = 0; |
| 80 | virtual DebuggerWrapper* debugger_wrapper() = 0; |
| 81 | virtual ClipboardService* clipboard_service() = 0; |
| 82 | |
| 83 | // Returns the thread that we perform I/O coordination on (network requests, |
| 84 | // communication with renderers, etc. |
| 85 | // NOTE: need to check the return value for NULL. |
[email protected] | ab820df | 2008-08-26 05:55:10 | [diff] [blame^] | 86 | virtual base::Thread* io_thread() = 0; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 87 | |
| 88 | // Returns the thread that we perform random file operations on. For code |
| 89 | // that wants to do I/O operations (not network requests or even file: URL |
| 90 | // requests), this is the thread to use to avoid blocking the UI thread. |
| 91 | // It might be nicer to have a thread pool for this kind of thing. |
[email protected] | ab820df | 2008-08-26 05:55:10 | [diff] [blame^] | 92 | virtual base::Thread* file_thread() = 0; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 93 | |
| 94 | // Returns the thread that is used for database operations such as history. |
[email protected] | ab820df | 2008-08-26 05:55:10 | [diff] [blame^] | 95 | virtual base::Thread* db_thread() = 0; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 96 | |
| 97 | virtual sandbox::BrokerServices* broker_services() = 0; |
| 98 | |
| 99 | virtual IconManager* icon_manager() = 0; |
| 100 | |
| 101 | virtual void InitBrokerServices(sandbox::BrokerServices*) = 0; |
| 102 | virtual AutomationProviderList* InitAutomationProviderList() = 0; |
| 103 | |
| 104 | virtual void InitDebuggerWrapper(int port) = 0; |
| 105 | |
| 106 | virtual unsigned int AddRefModule() = 0; |
| 107 | virtual unsigned int ReleaseModule() = 0; |
| 108 | |
| 109 | virtual bool IsShuttingDown() = 0; |
| 110 | |
| 111 | virtual ChromeViews::AcceleratorHandler* accelerator_handler() = 0; |
| 112 | |
| 113 | virtual printing::PrintJobManager* print_job_manager() = 0; |
| 114 | |
| 115 | virtual GoogleURLTracker* google_url_tracker() = 0; |
| 116 | |
| 117 | // Returns the locale used by the application. |
| 118 | virtual const std::wstring& GetApplicationLocale() = 0; |
| 119 | |
| 120 | virtual MemoryModel memory_model() = 0; |
| 121 | |
| 122 | virtual SuspendController* suspend_controller() = 0; |
| 123 | |
[email protected] | 1b2db1a | 2008-08-08 17:46:13 | [diff] [blame] | 124 | // TODO(beng): remove once XPFrame/VistaFrame are gone. |
| 125 | virtual bool IsUsingNewFrames() = 0; |
| 126 | |
[email protected] | d65cab7a | 2008-08-12 01:25:41 | [diff] [blame] | 127 | // Returns an event that is signaled when the browser shutdown. |
| 128 | virtual HANDLE shutdown_event() = 0; |
| 129 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 130 | private: |
| 131 | DISALLOW_EVIL_CONSTRUCTORS(BrowserProcess); |
| 132 | }; |
| 133 | |
| 134 | extern BrowserProcess* g_browser_process; |
| 135 | |
| 136 | #endif // CHROME_BROWSER_BROWSER_PROCESS_H__ |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 137 | |