blob: 908af1ab5dd9a73d010690306e583b3e2aef914a [file] [log] [blame]
license.botbf09a502008-08-24 00:55:551// 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.commit09911bf2008-07-26 23:55:294
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
18class AutomationProviderList;
19class ClipboardService;
20class GoogleURLTracker;
21class IconManager;
22class MetricsService;
23class NotificationService;
24class PrefService;
25class ProfileManager;
26class RenderProcessHost;
27class ResourceDispatcherHost;
28class DebuggerWrapper;
initial.commit09911bf2008-07-26 23:55:2929class WebAppInstallerService;
[email protected]d65cab7a2008-08-12 01:25:4130class SharedEvent;
initial.commit09911bf2008-07-26 23:55:2931class SuspendController;
32
[email protected]ab820df2008-08-26 05:55:1033namespace base {
34class Thread;
35}
initial.commit09911bf2008-07-26 23:55:2936namespace sandbox {
37class BrokerServices;
38}
39namespace ChromeViews {
40class AcceleratorHandler;
41}
42namespace printing {
43class PrintJobManager;
44}
45
46// NOT THREAD SAFE, call only from the main thread.
47// These functions shouldn't return NULL unless otherwise noted.
48class 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]ab820df2008-08-26 05:55:1086 virtual base::Thread* io_thread() = 0;
initial.commit09911bf2008-07-26 23:55:2987
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]ab820df2008-08-26 05:55:1092 virtual base::Thread* file_thread() = 0;
initial.commit09911bf2008-07-26 23:55:2993
94 // Returns the thread that is used for database operations such as history.
[email protected]ab820df2008-08-26 05:55:1095 virtual base::Thread* db_thread() = 0;
initial.commit09911bf2008-07-26 23:55:2996
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]1b2db1a2008-08-08 17:46:13124 // TODO(beng): remove once XPFrame/VistaFrame are gone.
125 virtual bool IsUsingNewFrames() = 0;
126
[email protected]d65cab7a2008-08-12 01:25:41127 // Returns an event that is signaled when the browser shutdown.
128 virtual HANDLE shutdown_event() = 0;
129
initial.commit09911bf2008-07-26 23:55:29130 private:
131 DISALLOW_EVIL_CONSTRUCTORS(BrowserProcess);
132};
133
134extern BrowserProcess* g_browser_process;
135
136#endif // CHROME_BROWSER_BROWSER_PROCESS_H__
license.botbf09a502008-08-24 00:55:55137