| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 | 7 |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 | 9 |
| 10 #if defined(OS_WIN) | 10 #if defined(OS_WIN) |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 locked_ = false; | 61 locked_ = false; |
| 62 foreground_window_ = NULL; | 62 foreground_window_ = NULL; |
| 63 } | 63 } |
| 64 | 64 |
| 65 bool locked() { | 65 bool locked() { |
| 66 DCHECK(CalledOnValidThread()); | 66 DCHECK(CalledOnValidThread()); |
| 67 return locked_; | 67 return locked_; |
| 68 } | 68 } |
| 69 | 69 |
| 70 private: | 70 private: |
| 71 #if defined(OS_WIN) || defined(OS_LINUX) |
| 72 // Timeout for the current browser process to respond. 20 seconds should be |
| 73 // enough. It's only used in Windows and Linux implementations. |
| 74 static const int kTimeoutInSeconds = 20; |
| 75 #endif |
| 76 |
| 71 bool locked_; | 77 bool locked_; |
| 72 gfx::NativeWindow foreground_window_; | 78 gfx::NativeWindow foreground_window_; |
| 73 | 79 |
| 74 #if defined(OS_WIN) | 80 #if defined(OS_WIN) |
| 75 // This ugly behemoth handles startup commands sent from another process. | 81 // This ugly behemoth handles startup commands sent from another process. |
| 76 LRESULT OnCopyData(HWND hwnd, const COPYDATASTRUCT* cds); | 82 LRESULT OnCopyData(HWND hwnd, const COPYDATASTRUCT* cds); |
| 77 | 83 |
| 78 LRESULT CALLBACK WndProc(HWND hwnd, | 84 LRESULT CALLBACK WndProc(HWND hwnd, |
| 79 UINT message, | 85 UINT message, |
| 80 WPARAM wparam, | 86 WPARAM wparam, |
| 81 LPARAM lparam); | 87 LPARAM lparam); |
| 82 | 88 |
| 83 static LRESULT CALLBACK WndProcStatic(HWND hwnd, | 89 static LRESULT CALLBACK WndProcStatic(HWND hwnd, |
| 84 UINT message, | 90 UINT message, |
| 85 WPARAM wparam, | 91 WPARAM wparam, |
| 86 LPARAM lparam) { | 92 LPARAM lparam) { |
| 87 ProcessSingleton* msg_wnd = reinterpret_cast<ProcessSingleton*>( | 93 ProcessSingleton* msg_wnd = reinterpret_cast<ProcessSingleton*>( |
| 88 GetWindowLongPtr(hwnd, GWLP_USERDATA)); | 94 GetWindowLongPtr(hwnd, GWLP_USERDATA)); |
| 89 return msg_wnd->WndProc(hwnd, message, wparam, lparam); | 95 return msg_wnd->WndProc(hwnd, message, wparam, lparam); |
| 90 } | 96 } |
| 91 | 97 |
| 92 HWND remote_window_; // The HWND_MESSAGE of another browser. | 98 HWND remote_window_; // The HWND_MESSAGE of another browser. |
| 93 HWND window_; // The HWND_MESSAGE window. | 99 HWND window_; // The HWND_MESSAGE window. |
| 94 #elif defined(OS_LINUX) | 100 #elif defined(OS_LINUX) |
| 95 // Set up a socket and sockaddr appropriate for messaging. | |
| 96 void SetupSocket(int* sock, struct sockaddr_un* addr); | |
| 97 | |
| 98 // Path in file system to the socket. | 101 // Path in file system to the socket. |
| 99 FilePath socket_path_; | 102 FilePath socket_path_; |
| 100 | 103 |
| 101 // Helper class for linux specific messages. LinuxWatcher is ref counted | 104 // Helper class for linux specific messages. LinuxWatcher is ref counted |
| 102 // because it posts messages between threads. | 105 // because it posts messages between threads. |
| 103 class LinuxWatcher; | 106 class LinuxWatcher; |
| 104 scoped_refptr<LinuxWatcher> watcher_; | 107 scoped_refptr<LinuxWatcher> watcher_; |
| 105 #endif | 108 #endif |
| 106 | 109 |
| 107 DISALLOW_COPY_AND_ASSIGN(ProcessSingleton); | 110 DISALLOW_COPY_AND_ASSIGN(ProcessSingleton); |
| 108 }; | 111 }; |
| 109 | 112 |
| 110 #endif // CHROME_BROWSER_PROCESS_SINGLETON_H_ | 113 #endif // CHROME_BROWSER_PROCESS_SINGLETON_H_ |
| OLD | NEW |