diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-18 22:04:28 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-18 22:04:28 +0000 |
commit | 19d7e9684e85feae1ecf9959baf07a94b01b1bce (patch) | |
tree | bd30e91dc44ae37bad8670b88eaca77ece65699a /chrome/browser/process_singleton.h | |
parent | 3851091de6451d26ba85318a9c36bd7f2923d2d8 (diff) | |
download | chromium_src-19d7e9684e85feae1ecf9959baf07a94b01b1bce.zip chromium_src-19d7e9684e85feae1ecf9959baf07a94b01b1bce.tar.gz chromium_src-19d7e9684e85feae1ecf9959baf07a94b01b1bce.tar.bz2 |
Implement skeletal ProcessSingleton on Linux to cut down on NOTIMPLEMENTED()s.
We now will refuse to run a second browser process if one is already running;
making the second invocation bring up new windows in the first remains left to
be implemented.
Review URL: http://codereview.chromium.org/20448
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9980 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/process_singleton.h')
-rw-r--r-- | chrome/browser/process_singleton.h | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/chrome/browser/process_singleton.h b/chrome/browser/process_singleton.h index 7e38def..4f514c4 100644 --- a/chrome/browser/process_singleton.h +++ b/chrome/browser/process_singleton.h @@ -5,8 +5,11 @@ #ifndef CHROME_BROWSER_PROCESS_SINGLETON_H_ #define CHROME_BROWSER_PROCESS_SINGLETON_H_ -#include <string> +#include "build/build_config.h" + +#if defined(OS_WIN) #include <windows.h> +#endif #include "base/basictypes.h" #include "base/file_path.h" @@ -18,8 +21,9 @@ // 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. +// Implementation notes: +// - the Windows implementation uses an invisible global message window; +// - the Linux implementation uses a Unix domain socket in ~/.chromium. class ProcessSingleton { public: @@ -27,14 +31,15 @@ class ProcessSingleton { ~ProcessSingleton(); // Returns true if another process was found and notified, false if we - // should continue with this process. Roughly based on Mozilla + // should continue with this process. + // Windows code roughly based on Mozilla. // // TODO(brettw): this will not handle all cases. If two process start up too - // close to each other, the window might not have been created yet for the + // close to each other, the Create() might not yet have happened for the // first one, so this function won't find it. bool NotifyOtherProcess(); - // Create the toplevel message window for IPC. + // Set ourselves up as the singleton instance. void Create(); // Blocks the dispatch of CopyData messages. @@ -47,13 +52,16 @@ class ProcessSingleton { locked_ = false; } - // This ugly behemoth handles startup commands sent from another process. - LRESULT OnCopyData(HWND hwnd, const COPYDATASTRUCT* cds); - // Looks for zombie renderer and plugin processes that could have survived. void HuntForZombieChromeProcesses(); private: + bool locked_; + +#if defined(OS_WIN) + // This ugly behemoth handles startup commands sent from another process. + LRESULT OnCopyData(HWND hwnd, const COPYDATASTRUCT* cds); + LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam, @@ -70,7 +78,13 @@ class ProcessSingleton { HWND remote_window_; // The HWND_MESSAGE of another browser. HWND window_; // The HWND_MESSAGE window. - bool locked_; +#elif defined(OS_LINUX) + // Set up a socket and sockaddr appropriate for messaging. + void SetupSocket(int* sock, struct sockaddr_un* addr); + + // Path in file system to the socket. + FilePath socket_path_; +#endif DISALLOW_COPY_AND_ASSIGN(ProcessSingleton); }; |