OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #include "chrome/browser/sync/util/query_helpers.h" | 5 #include "chrome/browser/sync/util/query_helpers.h" |
6 | 6 |
7 #if defined(OS_WINDOWS) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #endif | 9 #endif |
10 | 10 |
11 #include <limits> | 11 #include <limits> |
12 #include <string> | 12 #include <string> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "chrome/browser/sync/util/sync_types.h" | 15 #include "chrome/browser/sync/util/sync_types.h" |
16 | 16 |
17 using std::numeric_limits; | 17 using std::numeric_limits; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 int SqliteOpen(PathString filename, sqlite3** db) { | 58 int SqliteOpen(PathString filename, sqlite3** db) { |
59 int result = | 59 int result = |
60 #if PATHSTRING_IS_STD_STRING | 60 #if PATHSTRING_IS_STD_STRING |
61 sqlite3_open | 61 sqlite3_open |
62 #else | 62 #else |
63 sqlite3_open16 | 63 sqlite3_open16 |
64 #endif | 64 #endif |
65 (filename.c_str(), db); | 65 (filename.c_str(), db); |
66 LOG_IF(ERROR, SQLITE_OK != result) << "Error opening " << filename << ": " | 66 LOG_IF(ERROR, SQLITE_OK != result) << "Error opening " << filename << ": " |
67 << result; | 67 << result; |
68 #ifdef OS_WINDOWS | 68 #ifdef OS_WIN |
69 if (SQLITE_OK == result) { | 69 if (SQLITE_OK == result) { |
70 // Make sure we mark the db file as not indexed so since if any other app | 70 // Make sure we mark the db file as not indexed so since if any other app |
71 // opens it, it can break our db locking. | 71 // opens it, it can break our db locking. |
72 DWORD attrs = GetFileAttributes(filename.c_str()); | 72 DWORD attrs = GetFileAttributes(filename.c_str()); |
73 if (FILE_ATTRIBUTE_NORMAL == attrs) | 73 if (FILE_ATTRIBUTE_NORMAL == attrs) |
74 attrs = FILE_ATTRIBUTE_NOT_CONTENT_INDEXED; | 74 attrs = FILE_ATTRIBUTE_NOT_CONTENT_INDEXED; |
75 else | 75 else |
76 attrs = attrs | FILE_ATTRIBUTE_NOT_CONTENT_INDEXED; | 76 attrs = attrs | FILE_ATTRIBUTE_NOT_CONTENT_INDEXED; |
77 SetFileAttributes(filename.c_str(), attrs); | 77 SetFileAttributes(filename.c_str(), attrs); |
78 } | 78 } |
79 #endif // OS_WINDOWS | 79 #endif // OS_WIN |
80 // Be patient as we set pragmas. | 80 // Be patient as we set pragmas. |
81 sqlite3_busy_timeout(*db, numeric_limits<int>::max()); | 81 sqlite3_busy_timeout(*db, numeric_limits<int>::max()); |
82 #ifndef DISABLE_SQLITE_FULL_FSYNC | 82 #ifndef DISABLE_SQLITE_FULL_FSYNC |
83 ExecOrDie(*db, "PRAGMA fullfsync = 1"); | 83 ExecOrDie(*db, "PRAGMA fullfsync = 1"); |
84 #endif // DISABLE_SQLITE_FULL_FSYNC | 84 #endif // DISABLE_SQLITE_FULL_FSYNC |
85 ExecOrDie(*db, "PRAGMA synchronous = 2"); | 85 ExecOrDie(*db, "PRAGMA synchronous = 2"); |
86 sqlite3_busy_timeout(*db, 0); | 86 sqlite3_busy_timeout(*db, 0); |
87 return SQLITE_OK; | 87 return SQLITE_OK; |
88 } | 88 } |
89 | 89 |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 string result; | 272 string result; |
273 result.reserve(in.size() / 2); | 273 result.reserve(in.size() / 2); |
274 for (string::const_iterator i = in.begin(); i != in.end(); ++i) { | 274 for (string::const_iterator i = in.begin(); i != in.end(); ++i) { |
275 unsigned int c = *i - 'A'; | 275 unsigned int c = *i - 'A'; |
276 if (++i != in.end()) | 276 if (++i != in.end()) |
277 c = c | (static_cast<unsigned char>(*i - 'A') << 4); | 277 c = c | (static_cast<unsigned char>(*i - 'A') << 4); |
278 result.push_back(c); | 278 result.push_back(c); |
279 } | 279 } |
280 return result; | 280 return result; |
281 } | 281 } |
OLD | NEW |