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 // On Linux, when the user tries to launch a second copy of chrome, we check | 5 // On Linux, when the user tries to launch a second copy of chrome, we check |
6 // for a socket in the user's profile directory. If the socket file is open we | 6 // for a socket in the user's profile directory. If the socket file is open we |
7 // send a message to the first chrome browser process with the current | 7 // send a message to the first chrome browser process with the current |
8 // directory and second process command line flags. The second process then | 8 // directory and second process command line flags. The second process then |
9 // exits. | 9 // exits. |
10 // | 10 // |
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 return PROCESS_NONE; | 828 return PROCESS_NONE; |
829 } | 829 } |
830 | 830 |
831 if (retries == timeout_seconds) { | 831 if (retries == timeout_seconds) { |
832 // Retries failed. Kill the unresponsive chrome process and continue. | 832 // Retries failed. Kill the unresponsive chrome process and continue. |
833 if (!kill_unresponsive || !KillProcessByLockPath(lock_path_)) | 833 if (!kill_unresponsive || !KillProcessByLockPath(lock_path_)) |
834 return PROFILE_IN_USE; | 834 return PROFILE_IN_USE; |
835 return PROCESS_NONE; | 835 return PROCESS_NONE; |
836 } | 836 } |
837 | 837 |
838 base::PlatformThread::Sleep(1000 /* ms */); | 838 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(1)); |
839 } | 839 } |
840 | 840 |
841 timeval timeout = {timeout_seconds, 0}; | 841 timeval timeout = {timeout_seconds, 0}; |
842 setsockopt(socket.fd(), SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof(timeout)); | 842 setsockopt(socket.fd(), SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof(timeout)); |
843 | 843 |
844 // Found another process, prepare our command line | 844 // Found another process, prepare our command line |
845 // format is "START\0<current dir>\0<argv[0]>\0...\0<argv[n]>". | 845 // format is "START\0<current dir>\0<argv[0]>\0...\0<argv[n]>". |
846 std::string to_send(kStartToken); | 846 std::string to_send(kStartToken); |
847 to_send.push_back(kTokenDelimiter); | 847 to_send.push_back(kTokenDelimiter); |
848 | 848 |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
994 sock)); | 994 sock)); |
995 | 995 |
996 return true; | 996 return true; |
997 } | 997 } |
998 | 998 |
999 void ProcessSingleton::Cleanup() { | 999 void ProcessSingleton::Cleanup() { |
1000 UnlinkPath(socket_path_); | 1000 UnlinkPath(socket_path_); |
1001 UnlinkPath(cookie_path_); | 1001 UnlinkPath(cookie_path_); |
1002 UnlinkPath(lock_path_); | 1002 UnlinkPath(lock_path_); |
1003 } | 1003 } |
OLD | NEW |