| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_PROCESS_SINGLETON_H_ | 5 #ifndef CHROME_BROWSER_PROCESS_SINGLETON_H_ |
| 6 #define CHROME_BROWSER_PROCESS_SINGLETON_H_ | 6 #define CHROME_BROWSER_PROCESS_SINGLETON_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 | 10 |
| 11 #if defined(OS_WIN) | 11 #if defined(OS_WIN) |
| 12 #include <windows.h> | 12 #include <windows.h> |
| 13 #endif // defined(OS_WIN) | 13 #endif // defined(OS_WIN) |
| 14 | 14 |
| 15 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
| 18 #include "base/threading/non_thread_safe.h" | 18 #include "base/threading/non_thread_safe.h" |
| 19 #include "ui/gfx/native_widget_types.h" | 19 #include "ui/gfx/native_widget_types.h" |
| 20 | 20 |
| 21 #if defined(OS_POSIX) | 21 #if defined(OS_POSIX) |
| 22 #include "base/file_path.h" | 22 #include "base/file_path.h" |
| 23 #endif // defined(OS_POSIX) | 23 #endif // defined(OS_POSIX) |
| 24 | 24 |
| 25 #if defined(OS_LINUX) | 25 #if defined(OS_LINUX) || defined(OS_OPENBSD) |
| 26 #include "base/scoped_temp_dir.h" | 26 #include "base/scoped_temp_dir.h" |
| 27 #endif // defined(OS_LINUX) | 27 #endif // defined(OS_LINUX) || defined(OS_OPENBSD) |
| 28 | 28 |
| 29 class CommandLine; | 29 class CommandLine; |
| 30 class FilePath; | 30 class FilePath; |
| 31 | 31 |
| 32 // ProcessSingleton ---------------------------------------------------------- | 32 // ProcessSingleton ---------------------------------------------------------- |
| 33 // | 33 // |
| 34 // This class allows different browser processes to communicate with | 34 // This class allows different browser processes to communicate with |
| 35 // each other. It is named according to the user data directory, so | 35 // each other. It is named according to the user data directory, so |
| 36 // we can be sure that no more than one copy of the application can be | 36 // we can be sure that no more than one copy of the application can be |
| 37 // running at once with a given data directory. | 37 // running at once with a given data directory. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 60 // TODO(brettw): this will not handle all cases. If two process start up too | 60 // TODO(brettw): this will not handle all cases. If two process start up too |
| 61 // close to each other, the Create() might not yet have happened for the | 61 // close to each other, the Create() might not yet have happened for the |
| 62 // first one, so this function won't find it. | 62 // first one, so this function won't find it. |
| 63 NotifyResult NotifyOtherProcess(); | 63 NotifyResult NotifyOtherProcess(); |
| 64 | 64 |
| 65 // Notify another process, if available. Otherwise sets ourselves as the | 65 // Notify another process, if available. Otherwise sets ourselves as the |
| 66 // singleton instance. Returns PROCESS_NONE if we became the singleton | 66 // singleton instance. Returns PROCESS_NONE if we became the singleton |
| 67 // instance. | 67 // instance. |
| 68 NotifyResult NotifyOtherProcessOrCreate(); | 68 NotifyResult NotifyOtherProcessOrCreate(); |
| 69 | 69 |
| 70 #if defined(OS_LINUX) | 70 #if defined(OS_LINUX) || defined(OS_OPENBSD) |
| 71 // Exposed for testing. We use a timeout on Linux, and in tests we want | 71 // Exposed for testing. We use a timeout on Linux, and in tests we want |
| 72 // this timeout to be short. | 72 // this timeout to be short. |
| 73 NotifyResult NotifyOtherProcessWithTimeout(const CommandLine& command_line, | 73 NotifyResult NotifyOtherProcessWithTimeout(const CommandLine& command_line, |
| 74 int timeout_seconds, | 74 int timeout_seconds, |
| 75 bool kill_unresponsive); | 75 bool kill_unresponsive); |
| 76 NotifyResult NotifyOtherProcessWithTimeoutOrCreate( | 76 NotifyResult NotifyOtherProcessWithTimeoutOrCreate( |
| 77 const CommandLine& command_line, | 77 const CommandLine& command_line, |
| 78 int timeout_seconds); | 78 int timeout_seconds); |
| 79 #endif // defined(OS_LINUX) | 79 #endif // defined(OS_LINUX) || defined(OS_OPENBSD) |
| 80 | 80 |
| 81 #if defined(OS_WIN) && !defined(USE_AURA) | 81 #if defined(OS_WIN) && !defined(USE_AURA) |
| 82 // Used in specific cases to let us know that there is an existing instance | 82 // Used in specific cases to let us know that there is an existing instance |
| 83 // of Chrome running with this profile. In general, you should not use this | 83 // of Chrome running with this profile. In general, you should not use this |
| 84 // function. Instead consider using NotifyOtherProcessOrCreate(). | 84 // function. Instead consider using NotifyOtherProcessOrCreate(). |
| 85 // For non profile-specific method, use | 85 // For non profile-specific method, use |
| 86 // browser_util::IsBrowserAlreadyRunning(). | 86 // browser_util::IsBrowserAlreadyRunning(). |
| 87 bool FoundOtherProcessWindow() const { | 87 bool FoundOtherProcessWindow() const { |
| 88 return (NULL != remote_window_); | 88 return (NULL != remote_window_); |
| 89 } | 89 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 ProcessSingleton* msg_wnd = reinterpret_cast<ProcessSingleton*>( | 144 ProcessSingleton* msg_wnd = reinterpret_cast<ProcessSingleton*>( |
| 145 GetWindowLongPtr(hwnd, GWLP_USERDATA)); | 145 GetWindowLongPtr(hwnd, GWLP_USERDATA)); |
| 146 return msg_wnd->WndProc(hwnd, message, wparam, lparam); | 146 return msg_wnd->WndProc(hwnd, message, wparam, lparam); |
| 147 } | 147 } |
| 148 | 148 |
| 149 bool EscapeVirtualization(const FilePath& user_data_dir); | 149 bool EscapeVirtualization(const FilePath& user_data_dir); |
| 150 | 150 |
| 151 HWND remote_window_; // The HWND_MESSAGE of another browser. | 151 HWND remote_window_; // The HWND_MESSAGE of another browser. |
| 152 HWND window_; // The HWND_MESSAGE window. | 152 HWND window_; // The HWND_MESSAGE window. |
| 153 bool is_virtualized_; // Stuck inside Microsoft Softricity VM environment. | 153 bool is_virtualized_; // Stuck inside Microsoft Softricity VM environment. |
| 154 #elif defined(OS_LINUX) | 154 #elif defined(OS_LINUX) || defined(OS_OPENBSD) |
| 155 // Path in file system to the socket. | 155 // Path in file system to the socket. |
| 156 FilePath socket_path_; | 156 FilePath socket_path_; |
| 157 | 157 |
| 158 // Path in file system to the lock. | 158 // Path in file system to the lock. |
| 159 FilePath lock_path_; | 159 FilePath lock_path_; |
| 160 | 160 |
| 161 // Path in file system to the cookie file. | 161 // Path in file system to the cookie file. |
| 162 FilePath cookie_path_; | 162 FilePath cookie_path_; |
| 163 | 163 |
| 164 // Temporary directory to hold the socket. | 164 // Temporary directory to hold the socket. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 175 // File descriptor associated with the lockfile, valid between | 175 // File descriptor associated with the lockfile, valid between |
| 176 // |Create()| and |Cleanup()|. Two instances cannot have a lock on | 176 // |Create()| and |Cleanup()|. Two instances cannot have a lock on |
| 177 // the same file at the same time. | 177 // the same file at the same time. |
| 178 int lock_fd_; | 178 int lock_fd_; |
| 179 #endif | 179 #endif |
| 180 | 180 |
| 181 DISALLOW_COPY_AND_ASSIGN(ProcessSingleton); | 181 DISALLOW_COPY_AND_ASSIGN(ProcessSingleton); |
| 182 }; | 182 }; |
| 183 | 183 |
| 184 #endif // CHROME_BROWSER_PROCESS_SINGLETON_H_ | 184 #endif // CHROME_BROWSER_PROCESS_SINGLETON_H_ |
| OLD | NEW |