ExtensionSyncService: listen for relevant changes instead of being explicitly called...
[chromium-blink-merge.git] / chrome / browser / importer / firefox_profile_lock.cc
blobdab03810538310d7f89bb89c1ac850b3f3b2ce21
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
3 // found in the LICENSE file.
5 #include "chrome/browser/importer/firefox_profile_lock.h"
7 #include "base/files/file_path.h"
8 #include "base/threading/thread_restrictions.h"
10 // This class is based on Firefox code in:
11 // profile/dirserviceprovider/src/nsProfileLock.cpp
12 // The license block is:
14 /* ***** BEGIN LICENSE BLOCK *****
15 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
17 * The contents of this file are subject to the Mozilla Public License Version
18 * 1.1 (the "License"); you may not use this file except in compliance with
19 * the License. You may obtain a copy of the License at
20 * http://www.mozilla.org/MPL/
22 * Software distributed under the License is distributed on an "AS IS" basis,
23 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
24 * for the specific language governing rights and limitations under the
25 * License.
27 * The Original Code is mozilla.org code.
29 * The Initial Developer of the Original Code is
30 * Netscape Communications Corporation.
31 * Portions created by the Initial Developer are Copyright (C) 2002
32 * the Initial Developer. All Rights Reserved.
34 * Contributor(s):
35 * Conrad Carlen <ccarlen@netscape.com>
36 * Brendan Eich <brendan@mozilla.org>
37 * Colin Blake <colin@theblakes.com>
38 * Javier Pedemonte <pedemont@us.ibm.com>
39 * Mats Palmgren <mats.palmgren@bredband.net>
41 * Alternatively, the contents of this file may be used under the terms of
42 * either the GNU General Public License Version 2 or later (the "GPL"), or
43 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
44 * in which case the provisions of the GPL or the LGPL are applicable instead
45 * of those above. If you wish to allow use of your version of this file only
46 * under the terms of either the GPL or the LGPL, and not to allow others to
47 * use your version of this file under the terms of the MPL, indicate your
48 * decision by deleting the provisions above and replace them with the notice
49 * and other provisions required by the GPL or the LGPL. If you do not delete
50 * the provisions above, a recipient may use your version of this file under
51 * the terms of any one of the MPL, the GPL or the LGPL.
53 * ***** END LICENSE BLOCK ***** */
55 // static
56 #if defined(OS_MACOSX)
57 const base::FilePath::CharType* FirefoxProfileLock::kLockFileName =
58 FILE_PATH_LITERAL(".parentlock");
59 const base::FilePath::CharType* FirefoxProfileLock::kOldLockFileName =
60 FILE_PATH_LITERAL("parent.lock");
61 #elif defined(OS_POSIX)
62 // http://www.google.com/codesearch/p?hl=en#e_ObwTAVPyo/profile/dirserviceprovider/src/nsProfileLock.cpp&l=433
63 const base::FilePath::CharType* FirefoxProfileLock::kLockFileName =
64 FILE_PATH_LITERAL(".parentlock");
65 const base::FilePath::CharType* FirefoxProfileLock::kOldLockFileName =
66 FILE_PATH_LITERAL("lock");
67 #else
68 const base::FilePath::CharType* FirefoxProfileLock::kLockFileName =
69 FILE_PATH_LITERAL("parent.lock");
70 #endif
72 FirefoxProfileLock::FirefoxProfileLock(const base::FilePath& path) {
73 Init();
74 lock_file_ = path.Append(kLockFileName);
75 Lock();
78 FirefoxProfileLock::~FirefoxProfileLock() {
79 // Because this destructor happens in first run on the profile import thread,
80 // with no UI to jank, it's ok to allow deletion of the lock here.
81 base::ThreadRestrictions::ScopedAllowIO allow_io;
82 Unlock();