| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 944 FilePath remote_cookie_path = | 944 FilePath remote_cookie_path = |
| 945 socket_dir_.path().Append(chrome::kSingletonCookieFilename); | 945 socket_dir_.path().Append(chrome::kSingletonCookieFilename); |
| 946 UnlinkPath(socket_path_); | 946 UnlinkPath(socket_path_); |
| 947 UnlinkPath(cookie_path_); | 947 UnlinkPath(cookie_path_); |
| 948 if (!SymlinkPath(socket_target_path, socket_path_) || | 948 if (!SymlinkPath(socket_target_path, socket_path_) || |
| 949 !SymlinkPath(cookie, cookie_path_) || | 949 !SymlinkPath(cookie, cookie_path_) || |
| 950 !SymlinkPath(cookie, remote_cookie_path)) { | 950 !SymlinkPath(cookie, remote_cookie_path)) { |
| 951 // We've already locked things, so we can't have lost the startup race, | 951 // We've already locked things, so we can't have lost the startup race, |
| 952 // but something doesn't like us. | 952 // but something doesn't like us. |
| 953 LOG(ERROR) << "Failed to create symlinks."; | 953 LOG(ERROR) << "Failed to create symlinks."; |
| 954 socket_dir_.Delete(); | 954 if (!socket_dir_.Delete()) |
| 955 LOG(ERROR) << "Encountered a problem when deleting socket directory."; |
| 955 return false; | 956 return false; |
| 956 } | 957 } |
| 957 | 958 |
| 958 SetupSocket(socket_target_path.value(), &sock, &addr); | 959 SetupSocket(socket_target_path.value(), &sock, &addr); |
| 959 | 960 |
| 960 if (bind(sock, reinterpret_cast<sockaddr*>(&addr), sizeof(addr)) < 0) { | 961 if (bind(sock, reinterpret_cast<sockaddr*>(&addr), sizeof(addr)) < 0) { |
| 961 PLOG(ERROR) << "Failed to bind() " << socket_target_path.value(); | 962 PLOG(ERROR) << "Failed to bind() " << socket_target_path.value(); |
| 962 CloseSocket(sock); | 963 CloseSocket(sock); |
| 963 return false; | 964 return false; |
| 964 } | 965 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 977 sock)); | 978 sock)); |
| 978 | 979 |
| 979 return true; | 980 return true; |
| 980 } | 981 } |
| 981 | 982 |
| 982 void ProcessSingleton::Cleanup() { | 983 void ProcessSingleton::Cleanup() { |
| 983 UnlinkPath(socket_path_); | 984 UnlinkPath(socket_path_); |
| 984 UnlinkPath(cookie_path_); | 985 UnlinkPath(cookie_path_); |
| 985 UnlinkPath(lock_path_); | 986 UnlinkPath(lock_path_); |
| 986 } | 987 } |
| OLD | NEW |