| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2006-2008 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. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_FIREFOX_PROFILE_LOCK_H__ | |
| 6 #define CHROME_BROWSER_FIREFOX_PROFILE_LOCK_H__ | |
| 7 | |
| 8 #include <windows.h> | |
| 9 | |
| 10 #include <string> | |
| 11 | |
| 12 #include "base/basictypes.h" | |
| 13 #include "testing/gtest/include/gtest/gtest_prod.h" | |
| 14 | |
| 15 // Firefox is designed to allow only one application to access its | |
| 16 // profile at the same time. | |
| 17 // Reference: | |
| 18 // http://kb.mozillazine.org/Profile_in_use | |
| 19 // | |
| 20 // This class is based on Firefox code in: | |
| 21 // profile/dirserviceprovider/src/nsProfileLock.cpp | |
| 22 // The license block is: | |
| 23 | |
| 24 /* ***** BEGIN LICENSE BLOCK ***** | |
| 25 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | |
| 26 * | |
| 27 * The contents of this file are subject to the Mozilla Public License Version | |
| 28 * 1.1 (the "License"); you may not use this file except in compliance with | |
| 29 * the License. You may obtain a copy of the License at | |
| 30 * http://www.mozilla.org/MPL/ | |
| 31 * | |
| 32 * Software distributed under the License is distributed on an "AS IS" basis, | |
| 33 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |
| 34 * for the specific language governing rights and limitations under the | |
| 35 * License. | |
| 36 * | |
| 37 * The Original Code is mozilla.org code. | |
| 38 * | |
| 39 * The Initial Developer of the Original Code is | |
| 40 * Netscape Communications Corporation. | |
| 41 * Portions created by the Initial Developer are Copyright (C) 2002 | |
| 42 * the Initial Developer. All Rights Reserved. | |
| 43 * | |
| 44 * Contributor(s): | |
| 45 * Conrad Carlen <ccarlen@netscape.com> | |
| 46 * Brendan Eich <brendan@mozilla.org> | |
| 47 * Colin Blake <colin@theblakes.com> | |
| 48 * Javier Pedemonte <pedemont@us.ibm.com> | |
| 49 * Mats Palmgren <mats.palmgren@bredband.net> | |
| 50 * | |
| 51 * Alternatively, the contents of this file may be used under the terms of | |
| 52 * either the GNU General Public License Version 2 or later (the "GPL"), or | |
| 53 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), | |
| 54 * in which case the provisions of the GPL or the LGPL are applicable instead | |
| 55 * of those above. If you wish to allow use of your version of this file only | |
| 56 * under the terms of either the GPL or the LGPL, and not to allow others to | |
| 57 * use your version of this file under the terms of the MPL, indicate your | |
| 58 * decision by deleting the provisions above and replace them with the notice | |
| 59 * and other provisions required by the GPL or the LGPL. If you do not delete | |
| 60 * the provisions above, a recipient may use your version of this file under | |
| 61 * the terms of any one of the MPL, the GPL or the LGPL. | |
| 62 * | |
| 63 * ***** END LICENSE BLOCK ***** */ | |
| 64 | |
| 65 class FirefoxProfileLock { | |
| 66 public: | |
| 67 explicit FirefoxProfileLock(const std::wstring& path); | |
| 68 ~FirefoxProfileLock(); | |
| 69 | |
| 70 // Locks and releases the profile. | |
| 71 void Lock(); | |
| 72 void Unlock(); | |
| 73 | |
| 74 // Returns true if we lock the profile successfully. | |
| 75 bool HasAcquired(); | |
| 76 | |
| 77 private: | |
| 78 FRIEND_TEST(FirefoxImporterTest, ProfileLock); | |
| 79 FRIEND_TEST(FirefoxImporterTest, ProfileLockOrphaned); | |
| 80 | |
| 81 // The name of the lock file. | |
| 82 static wchar_t kLockFileName[]; | |
| 83 | |
| 84 // Full path of the lock file in the profile folder. | |
| 85 std::wstring lock_file_; | |
| 86 | |
| 87 // The handle of the lock file. | |
| 88 HANDLE lock_handle_; | |
| 89 | |
| 90 DISALLOW_EVIL_CONSTRUCTORS(FirefoxProfileLock); | |
| 91 }; | |
| 92 | |
| 93 #endif // CHROME_BROWSER_FIREFOX_PROFILE_LOCK_H__ | |
| 94 | |
| OLD | NEW |