| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CHROME_BROWSER_SYNC_UTIL_USER_SETTINGS_H_ | 5 #ifndef CHROME_BROWSER_SYNC_UTIL_USER_SETTINGS_H_ |
| 6 #define CHROME_BROWSER_SYNC_UTIL_USER_SETTINGS_H_ | 6 #define CHROME_BROWSER_SYNC_UTIL_USER_SETTINGS_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/lock.h" | 12 #include "base/synchronization/lock.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 | 14 |
| 15 extern "C" struct sqlite3; | 15 extern "C" struct sqlite3; |
| 16 | 16 |
| 17 class FilePath; | 17 class FilePath; |
| 18 | 18 |
| 19 namespace browser_sync { | 19 namespace browser_sync { |
| 20 | 20 |
| 21 void ExecOrDie(sqlite3* dbhandle, const char *query); | 21 void ExecOrDie(sqlite3* dbhandle, const char *query); |
| 22 std::string APEncode(const std::string& in); | 22 std::string APEncode(const std::string& in); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 | 72 |
| 73 // Get a unique ID suitable for use as the client ID. This ID has the | 73 // Get a unique ID suitable for use as the client ID. This ID has the |
| 74 // lifetime of the user settings database. You may use this ID if your | 74 // lifetime of the user settings database. You may use this ID if your |
| 75 // operating environment does not provide its own unique client ID. | 75 // operating environment does not provide its own unique client ID. |
| 76 std::string GetClientId(); | 76 std::string GetClientId(); |
| 77 | 77 |
| 78 protected: | 78 protected: |
| 79 struct ScopedDBHandle { | 79 struct ScopedDBHandle { |
| 80 explicit ScopedDBHandle(UserSettings* settings); | 80 explicit ScopedDBHandle(UserSettings* settings); |
| 81 inline sqlite3* get() const { return *handle_; } | 81 inline sqlite3* get() const { return *handle_; } |
| 82 AutoLock mutex_lock_; | 82 base::AutoLock mutex_lock_; |
| 83 sqlite3** const handle_; | 83 sqlite3** const handle_; |
| 84 }; | 84 }; |
| 85 | 85 |
| 86 friend struct ScopedDBHandle; | 86 friend struct ScopedDBHandle; |
| 87 friend class URLFactory; | 87 friend class URLFactory; |
| 88 | 88 |
| 89 void MigrateOldVersionsAsNeeded(sqlite3* const handle, int current_version); | 89 void MigrateOldVersionsAsNeeded(sqlite3* const handle, int current_version); |
| 90 | 90 |
| 91 private: | 91 private: |
| 92 std::string email_; | 92 std::string email_; |
| 93 mutable Lock mutex_; // protects email_. | 93 mutable base::Lock mutex_; // protects email_. |
| 94 | 94 |
| 95 // We keep a single dbhandle. | 95 // We keep a single dbhandle. |
| 96 sqlite3* dbhandle_; | 96 sqlite3* dbhandle_; |
| 97 Lock dbhandle_mutex_; | 97 base::Lock dbhandle_mutex_; |
| 98 | 98 |
| 99 // TODO(sync): Use in-memory cache for service auth tokens on posix. | 99 // TODO(sync): Use in-memory cache for service auth tokens on posix. |
| 100 // Have someone competent in Windows switch it over to not use Sqlite in the | 100 // Have someone competent in Windows switch it over to not use Sqlite in the |
| 101 // future. | 101 // future. |
| 102 #ifndef OS_WIN | 102 #ifndef OS_WIN |
| 103 typedef std::map<std::string, std::string> ServiceTokenMap; | 103 typedef std::map<std::string, std::string> ServiceTokenMap; |
| 104 ServiceTokenMap service_tokens_; | 104 ServiceTokenMap service_tokens_; |
| 105 #endif // OS_WIN | 105 #endif // OS_WIN |
| 106 | 106 |
| 107 DISALLOW_COPY_AND_ASSIGN(UserSettings); | 107 DISALLOW_COPY_AND_ASSIGN(UserSettings); |
| 108 }; | 108 }; |
| 109 | 109 |
| 110 } // namespace browser_sync | 110 } // namespace browser_sync |
| 111 | 111 |
| 112 #endif // CHROME_BROWSER_SYNC_UTIL_USER_SETTINGS_H_ | 112 #endif // CHROME_BROWSER_SYNC_UTIL_USER_SETTINGS_H_ |
| OLD | NEW |