diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-18 00:34:21 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-18 00:34:21 +0000 |
commit | 7c47ae3e1448b0ae65d7d75a7ed82d66334b11f8 (patch) | |
tree | d718ace931258ad51fbcac618030aab236fb1bfb /chrome/browser | |
parent | e4844e11f1f5a9ee8707b1f6f79aa3de54db2248 (diff) | |
download | chromium_src-7c47ae3e1448b0ae65d7d75a7ed82d66334b11f8.zip chromium_src-7c47ae3e1448b0ae65d7d75a7ed82d66334b11f8.tar.gz chromium_src-7c47ae3e1448b0ae65d7d75a7ed82d66334b11f8.tar.bz2 |
Rename MessageWindow to ProcessSingleton in anticipation of more refactoring.
Review URL: http://codereview.chromium.org/20437
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9923 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/browser.vcproj | 4 | ||||
-rw-r--r-- | chrome/browser/browser_init.h | 2 | ||||
-rw-r--r-- | chrome/browser/browser_main.cc | 14 | ||||
-rw-r--r-- | chrome/browser/process_singleton.cc (renamed from chrome/browser/message_window.cc) | 18 | ||||
-rw-r--r-- | chrome/browser/process_singleton.h (renamed from chrome/browser/message_window.h) | 30 |
5 files changed, 35 insertions, 33 deletions
diff --git a/chrome/browser/browser.vcproj b/chrome/browser/browser.vcproj index d341b5a..7953983 100644 --- a/chrome/browser/browser.vcproj +++ b/chrome/browser/browser.vcproj @@ -410,11 +410,11 @@ > </File> <File - RelativePath=".\message_window.cc" + RelativePath=".\process_singleton.cc" > </File> <File - RelativePath=".\message_window.h" + RelativePath=".\process_singleton.h" > </File> <File diff --git a/chrome/browser/browser_init.h b/chrome/browser/browser_init.h index fb3a5d6..e37ab69 100644 --- a/chrome/browser/browser_init.h +++ b/chrome/browser/browser_init.h @@ -90,7 +90,7 @@ class BrowserInit { // process (via the WM_COPYDATA message). |command_line| holds the command // line we need to process - either from this process or from some other one // (if |process_startup| is true and we are being called from - // MessageWindow::OnCopyData). + // ProcessSingleton::OnCopyData). static bool ProcessCommandLine(const CommandLine& command_line, const std::wstring& cur_dir, PrefService* prefs, bool process_startup, diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc index d7dd579..e7cd0a1 100644 --- a/chrome/browser/browser_main.cc +++ b/chrome/browser/browser_main.cc @@ -68,8 +68,8 @@ #include "chrome/browser/browser_trial.h" #include "chrome/browser/extensions/extension_protocols.h" #include "chrome/browser/jankometer.h" -#include "chrome/browser/message_window.h" #include "chrome/browser/metrics/user_metrics.h" +#include "chrome/browser/process_singleton.h" #include "chrome/browser/net/dns_global.h" #include "chrome/browser/net/sdch_dictionary_fetcher.h" #include "chrome/browser/net/url_fixer_upper.h" @@ -230,7 +230,7 @@ int BrowserMain(const MainFunctionParams& parameters) { FilePath user_data_dir; PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); - MessageWindow message_window(user_data_dir); + ProcessSingleton process_singleton(user_data_dir); bool is_first_run = FirstRun::IsChromeFirstRun() || parsed_command_line.HasSwitch(switches::kFirstRun); @@ -399,10 +399,10 @@ int BrowserMain(const MainFunctionParams& parameters) { return FirstRun::ImportNow(profile, parsed_command_line); // When another process is running, use it instead of starting us. - if (message_window.NotifyOtherProcess()) + if (process_singleton.NotifyOtherProcess()) return ResultCodes::NORMAL_EXIT; - message_window.HuntForZombieChromeProcesses(); + process_singleton.HuntForZombieChromeProcesses(); // Do the tasks if chrome has been upgraded while it was last running. if (!already_running && DoUpgradeTasks(parsed_command_line)) { @@ -419,7 +419,7 @@ int BrowserMain(const MainFunctionParams& parameters) { if (CheckMachineLevelInstall()) return ResultCodes::MACHINE_LEVEL_INSTALL_EXISTS; - message_window.Create(); + process_singleton.Create(); // Show the First Run UI if this is the first time Chrome has been run on // this computer, or we're being compelled to do so by a command line flag. @@ -429,9 +429,9 @@ int BrowserMain(const MainFunctionParams& parameters) { if (is_first_run && !first_run_ui_bypass) { // We need to avoid dispatching new tabs when we are doing the import // because that will lead to data corruption or a crash. Lock() does that. - message_window.Lock(); + process_singleton.Lock(); OpenFirstRunDialog(profile); - message_window.Unlock(); + process_singleton.Unlock(); } // Sets things up so that if we crash from this point on, a dialog will diff --git a/chrome/browser/message_window.cc b/chrome/browser/process_singleton.cc index 2174667..61a6d9f 100644 --- a/chrome/browser/message_window.cc +++ b/chrome/browser/process_singleton.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/message_window.h" +#include "chrome/browser/process_singleton.h" #include "base/base_paths.h" #include "base/command_line.h" @@ -34,7 +34,7 @@ BOOL CALLBACK BrowserWindowEnumeration(HWND window, LPARAM param) { } // namespace -MessageWindow::MessageWindow(const FilePath& user_data_dir) +ProcessSingleton::ProcessSingleton(const FilePath& user_data_dir) : window_(NULL), locked_(false) { // Look for a Chrome instance that uses the same profile directory: @@ -44,12 +44,12 @@ MessageWindow::MessageWindow(const FilePath& user_data_dir) user_data_dir.ToWStringHack().c_str()); } -MessageWindow::~MessageWindow() { +ProcessSingleton::~ProcessSingleton() { if (window_) DestroyWindow(window_); } -bool MessageWindow::NotifyOtherProcess() { +bool ProcessSingleton::NotifyOtherProcess() { if (!remote_window_) return false; @@ -127,14 +127,14 @@ bool MessageWindow::NotifyOtherProcess() { return false; } -void MessageWindow::Create() { +void ProcessSingleton::Create() { DCHECK(!window_); DCHECK(!remote_window_); HINSTANCE hinst = GetModuleHandle(NULL); WNDCLASSEX wc = {0}; wc.cbSize = sizeof(wc); - wc.lpfnWndProc = MessageWindow::WndProcStatic; + wc.lpfnWndProc = ProcessSingleton::WndProcStatic; wc.hInstance = hinst; wc.lpszClassName = chrome::kMessageWindowClass; RegisterClassEx(&wc); @@ -151,7 +151,7 @@ void MessageWindow::Create() { win_util::SetWindowUserData(window_, this); } -LRESULT MessageWindow::OnCopyData(HWND hwnd, const COPYDATASTRUCT* cds) { +LRESULT ProcessSingleton::OnCopyData(HWND hwnd, const COPYDATASTRUCT* cds) { // Ignore the request if the browser process is already in shutdown path. if (!g_browser_process || g_browser_process->IsShuttingDown()) { LOG(WARNING) << "Not handling WM_COPYDATA as browser is shutting down"; @@ -237,7 +237,7 @@ LRESULT MessageWindow::OnCopyData(HWND hwnd, const COPYDATASTRUCT* cds) { return TRUE; } -LRESULT CALLBACK MessageWindow::WndProc(HWND hwnd, UINT message, +LRESULT CALLBACK ProcessSingleton::WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) { switch (message) { case WM_COPYDATA: @@ -250,7 +250,7 @@ LRESULT CALLBACK MessageWindow::WndProc(HWND hwnd, UINT message, return ::DefWindowProc(hwnd, message, wparam, lparam); } -void MessageWindow::HuntForZombieChromeProcesses() { +void ProcessSingleton::HuntForZombieChromeProcesses() { // Detecting dead renderers is simple: // - The process is named chrome.exe. // - The process' parent doesn't exist anymore. diff --git a/chrome/browser/message_window.h b/chrome/browser/process_singleton.h index 632c82d..7e38def 100644 --- a/chrome/browser/message_window.h +++ b/chrome/browser/process_singleton.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_MESSAGE_WINDOW_H_ -#define CHROME_BROWSER_MESSAGE_WINDOW_H_ +#ifndef CHROME_BROWSER_PROCESS_SINGLETON_H_ +#define CHROME_BROWSER_PROCESS_SINGLETON_H_ #include <string> #include <windows.h> @@ -11,18 +11,20 @@ #include "base/basictypes.h" #include "base/file_path.h" -// MessageWindow ------------------------------------------------------------- +// ProcessSingleton ---------------------------------------------------------- // -// Class for dealing with the invisible global message window for IPC. This -// window allows different browser processes to communicate with each other. -// It is named according to the user data directory, so we can be sure that -// no more than one copy of the application can be running at once with a -// given data directory. +// This class allows different browser processes to communicate with +// each other. It is named according to the user data directory, so +// we can be sure that no more than one copy of the application can be +// running at once with a given data directory. +// +// The Windows implementation uses an invisible global message window for +// IPC. -class MessageWindow { +class ProcessSingleton { public: - explicit MessageWindow(const FilePath& user_data_dir); - ~MessageWindow(); + explicit ProcessSingleton(const FilePath& user_data_dir); + ~ProcessSingleton(); // Returns true if another process was found and notified, false if we // should continue with this process. Roughly based on Mozilla @@ -61,7 +63,7 @@ class MessageWindow { UINT message, WPARAM wparam, LPARAM lparam) { - MessageWindow* msg_wnd = reinterpret_cast<MessageWindow*>( + ProcessSingleton* msg_wnd = reinterpret_cast<ProcessSingleton*>( GetWindowLongPtr(hwnd, GWLP_USERDATA)); return msg_wnd->WndProc(hwnd, message, wparam, lparam); } @@ -70,7 +72,7 @@ class MessageWindow { HWND window_; // The HWND_MESSAGE window. bool locked_; - DISALLOW_COPY_AND_ASSIGN(MessageWindow); + DISALLOW_COPY_AND_ASSIGN(ProcessSingleton); }; -#endif // #ifndef CHROME_BROWSER_MESSAGE_WINDOW_H_ +#endif // #ifndef CHROME_BROWSER_PROCESS_SINGLETON_H_ |