| OLD | NEW |
| 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008 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 #include "chrome/browser/importer/firefox_profile_lock.h" | 5 #include "chrome/browser/importer/firefox_profile_lock.h" |
| 6 | 6 |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 #include <sys/stat.h> | 8 #include <sys/stat.h> |
| 9 #include <sys/types.h> | 9 #include <sys/types.h> |
| 10 | 10 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 if (HasAcquired()) | 63 if (HasAcquired()) |
| 64 return; | 64 return; |
| 65 lock_fd_ = open(lock_file_.value().c_str(), O_CREAT | O_EXCL, 0644); | 65 lock_fd_ = open(lock_file_.value().c_str(), O_CREAT | O_EXCL, 0644); |
| 66 } | 66 } |
| 67 | 67 |
| 68 void FirefoxProfileLock::Unlock() { | 68 void FirefoxProfileLock::Unlock() { |
| 69 if (!HasAcquired()) | 69 if (!HasAcquired()) |
| 70 return; | 70 return; |
| 71 close(lock_fd_); | 71 close(lock_fd_); |
| 72 lock_fd_ = -1; | 72 lock_fd_ = -1; |
| 73 file_util::Delete(lock_file_, false); |
| 73 } | 74 } |
| 74 | 75 |
| 75 bool FirefoxProfileLock::HasAcquired() { | 76 bool FirefoxProfileLock::HasAcquired() { |
| 76 return (lock_fd_ >= 0); | 77 return (lock_fd_ >= 0); |
| 77 } | 78 } |
| OLD | NEW |