Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1069)

Side by Side Diff: sql/connection.cc

Issue 1533283002: Switch to standard integer types in xxx/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sql/connection.h ('k') | sql/connection_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "sql/connection.h" 5 #include "sql/connection.h"
6 6
7 #include <stddef.h>
8 #include <stdint.h>
7 #include <string.h> 9 #include <string.h>
8 10
9 #include "base/bind.h" 11 #include "base/bind.h"
10 #include "base/debug/dump_without_crashing.h" 12 #include "base/debug/dump_without_crashing.h"
11 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
12 #include "base/files/file_util.h" 14 #include "base/files/file_util.h"
13 #include "base/format_macros.h" 15 #include "base/format_macros.h"
14 #include "base/json/json_file_value_serializer.h" 16 #include "base/json/json_file_value_serializer.h"
15 #include "base/lazy_instance.h" 17 #include "base/lazy_instance.h"
16 #include "base/logging.h" 18 #include "base/logging.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 (attachment_point[i] >= 'a' && attachment_point[i] <= 'z') || 115 (attachment_point[i] >= 'a' && attachment_point[i] <= 'z') ||
114 (attachment_point[i] >= 'A' && attachment_point[i] <= 'Z') || 116 (attachment_point[i] >= 'A' && attachment_point[i] <= 'Z') ||
115 attachment_point[i] == '_')) { 117 attachment_point[i] == '_')) {
116 return false; 118 return false;
117 } 119 }
118 } 120 }
119 return true; 121 return true;
120 } 122 }
121 123
122 void RecordSqliteMemory10Min() { 124 void RecordSqliteMemory10Min() {
123 const int64 used = sqlite3_memory_used(); 125 const int64_t used = sqlite3_memory_used();
124 UMA_HISTOGRAM_COUNTS("Sqlite.MemoryKB.TenMinutes", used / 1024); 126 UMA_HISTOGRAM_COUNTS("Sqlite.MemoryKB.TenMinutes", used / 1024);
125 } 127 }
126 128
127 void RecordSqliteMemoryHour() { 129 void RecordSqliteMemoryHour() {
128 const int64 used = sqlite3_memory_used(); 130 const int64_t used = sqlite3_memory_used();
129 UMA_HISTOGRAM_COUNTS("Sqlite.MemoryKB.OneHour", used / 1024); 131 UMA_HISTOGRAM_COUNTS("Sqlite.MemoryKB.OneHour", used / 1024);
130 } 132 }
131 133
132 void RecordSqliteMemoryDay() { 134 void RecordSqliteMemoryDay() {
133 const int64 used = sqlite3_memory_used(); 135 const int64_t used = sqlite3_memory_used();
134 UMA_HISTOGRAM_COUNTS("Sqlite.MemoryKB.OneDay", used / 1024); 136 UMA_HISTOGRAM_COUNTS("Sqlite.MemoryKB.OneDay", used / 1024);
135 } 137 }
136 138
137 void RecordSqliteMemoryWeek() { 139 void RecordSqliteMemoryWeek() {
138 const int64 used = sqlite3_memory_used(); 140 const int64_t used = sqlite3_memory_used();
139 UMA_HISTOGRAM_COUNTS("Sqlite.MemoryKB.OneWeek", used / 1024); 141 UMA_HISTOGRAM_COUNTS("Sqlite.MemoryKB.OneWeek", used / 1024);
140 } 142 }
141 143
142 // SQLite automatically calls sqlite3_initialize() lazily, but 144 // SQLite automatically calls sqlite3_initialize() lazily, but
143 // sqlite3_initialize() uses double-checked locking and thus can have 145 // sqlite3_initialize() uses double-checked locking and thus can have
144 // data races. 146 // data races.
145 // 147 //
146 // TODO(shess): Another alternative would be to have 148 // TODO(shess): Another alternative would be to have
147 // sqlite3_initialize() called as part of process bring-up. If this 149 // sqlite3_initialize() called as part of process bring-up. If this
148 // is changed, remove the dynamic_annotations dependency in sql.gyp. 150 // is changed, remove the dynamic_annotations dependency in sql.gyp.
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 } 838 }
837 839
838 // TODO(shess): Since this is only called in an error situation, it might be 840 // TODO(shess): Since this is only called in an error situation, it might be
839 // prudent to rewrite in terms of SQLite API calls, and mark the function const. 841 // prudent to rewrite in terms of SQLite API calls, and mark the function const.
840 std::string Connection::CollectCorruptionInfo() { 842 std::string Connection::CollectCorruptionInfo() {
841 AssertIOAllowed(); 843 AssertIOAllowed();
842 844
843 // If the file cannot be accessed it is unlikely that an integrity check will 845 // If the file cannot be accessed it is unlikely that an integrity check will
844 // turn up actionable information. 846 // turn up actionable information.
845 const base::FilePath db_path = DbPath(); 847 const base::FilePath db_path = DbPath();
846 int64 db_size = -1; 848 int64_t db_size = -1;
847 if (!base::GetFileSize(db_path, &db_size) || db_size < 0) 849 if (!base::GetFileSize(db_path, &db_size) || db_size < 0)
848 return std::string(); 850 return std::string();
849 851
850 // Buffer for accumulating debugging info about the error. Place 852 // Buffer for accumulating debugging info about the error. Place
851 // more-relevant information earlier, in case things overflow the 853 // more-relevant information earlier, in case things overflow the
852 // fixed-size reporting buffer. 854 // fixed-size reporting buffer.
853 std::string debug_info; 855 std::string debug_info;
854 base::StringAppendF(&debug_info, "SQLITE_CORRUPT, db size %" PRId64 "\n", 856 base::StringAppendF(&debug_info, "SQLITE_CORRUPT, db size %" PRId64 "\n",
855 db_size); 857 db_size);
856 858
857 // Only check files up to 8M to keep things from blocking too long. 859 // Only check files up to 8M to keep things from blocking too long.
858 const int64 kMaxIntegrityCheckSize = 8192 * 1024; 860 const int64_t kMaxIntegrityCheckSize = 8192 * 1024;
859 if (db_size > kMaxIntegrityCheckSize) { 861 if (db_size > kMaxIntegrityCheckSize) {
860 debug_info += "integrity_check skipped due to size\n"; 862 debug_info += "integrity_check skipped due to size\n";
861 } else { 863 } else {
862 std::vector<std::string> messages; 864 std::vector<std::string> messages;
863 865
864 // TODO(shess): FullIntegrityCheck() splits into a vector while this joins 866 // TODO(shess): FullIntegrityCheck() splits into a vector while this joins
865 // into a string. Probably should be refactored. 867 // into a string. Probably should be refactored.
866 const base::TimeTicks before = base::TimeTicks::Now(); 868 const base::TimeTicks before = base::TimeTicks::Now();
867 FullIntegrityCheck(&messages); 869 FullIntegrityCheck(&messages);
868 base::StringAppendF( 870 base::StringAppendF(
(...skipping 1111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1980 ignore_result(Execute(kNoWritableSchema)); 1982 ignore_result(Execute(kNoWritableSchema));
1981 1983
1982 return ret; 1984 return ret;
1983 } 1985 }
1984 1986
1985 base::TimeTicks TimeSource::Now() { 1987 base::TimeTicks TimeSource::Now() {
1986 return base::TimeTicks::Now(); 1988 return base::TimeTicks::Now();
1987 } 1989 }
1988 1990
1989 } // namespace sql 1991 } // namespace sql
OLDNEW
« no previous file with comments | « sql/connection.h ('k') | sql/connection_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698