diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-12 11:33:28 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-12 11:33:28 +0000 |
commit | d4f06fa99aa8f04fedbb336fe4e115831b2bc6ca (patch) | |
tree | 97fb1484630c693930a2e7a9f0918726400fe8d1 /chrome/browser/importer/firefox_profile_lock.cc | |
parent | 0d50e405a5fe5af628eb16ecae38962ce371a39d (diff) | |
download | chromium_src-d4f06fa99aa8f04fedbb336fe4e115831b2bc6ca.zip chromium_src-d4f06fa99aa8f04fedbb336fe4e115831b2bc6ca.tar.gz chromium_src-d4f06fa99aa8f04fedbb336fe4e115831b2bc6ca.tar.bz2 |
browser porting, part 2 - importer
Review URL: http://codereview.chromium.org/12688
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6885 0039d316-1c4b-4281-b951-d872f2087c98
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); -} - - |