diff options
Diffstat (limited to 'chrome/browser/importer/firefox_profile_lock.cc')
-rw-r--r-- | chrome/browser/importer/firefox_profile_lock.cc | 33 |
1 files changed, 6 insertions, 27 deletions
diff --git a/chrome/browser/importer/firefox_profile_lock.cc b/chrome/browser/importer/firefox_profile_lock.cc index aaab891..d033002 100644 --- a/chrome/browser/importer/firefox_profile_lock.cc +++ b/chrome/browser/importer/firefox_profile_lock.cc @@ -4,7 +4,7 @@ #include "chrome/browser/importer/firefox_profile_lock.h" -#include "base/file_util.h" +#include "base/file_path.h" // This class is based on Firefox code in: // profile/dirserviceprovider/src/nsProfileLock.cpp @@ -52,36 +52,15 @@ * ***** END LICENSE BLOCK ***** */ // static -wchar_t FirefoxProfileLock::kLockFileName[] = L"parent.lock"; +const FilePath::CharType* FirefoxProfileLock::kLockFileName = + FILE_PATH_LITERAL("parent.lock"); -FirefoxProfileLock::FirefoxProfileLock(const std::wstring& path) - : lock_handle_(INVALID_HANDLE_VALUE) { - lock_file_ = path; - file_util::AppendToPath(&lock_file_, kLockFileName); +FirefoxProfileLock::FirefoxProfileLock(const std::wstring& path) { + Init(); + lock_file_ = FilePath::FromWStringHack(path).Append(kLockFileName); Lock(); } FirefoxProfileLock::~FirefoxProfileLock() { Unlock(); } - -void FirefoxProfileLock::Lock() { - if (HasAcquired()) - return; - lock_handle_ = CreateFile(lock_file_.c_str(), GENERIC_READ | GENERIC_WRITE, - 0, NULL, OPEN_ALWAYS, FILE_FLAG_DELETE_ON_CLOSE, - NULL); -} - -void FirefoxProfileLock::Unlock() { - if (!HasAcquired()) - return; - CloseHandle(lock_handle_); - lock_handle_ = INVALID_HANDLE_VALUE; -} - -bool FirefoxProfileLock::HasAcquired() { - return (lock_handle_ != INVALID_HANDLE_VALUE); -} - - |