 Chromium Code Reviews
 Chromium Code Reviews Issue 2107493002:
  Offer user to send feedback from profile error dialog  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 2107493002:
  Offer user to send feedback from profile error dialog  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| OLD | NEW | 
|---|---|
| 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 <limits.h> | 7 #include <limits.h> | 
| 8 #include <stddef.h> | 8 #include <stddef.h> | 
| 9 #include <stdint.h> | 9 #include <stdint.h> | 
| 10 #include <string.h> | 10 #include <string.h> | 
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 236 // static | 236 // static | 
| 237 bool Connection::IsExpectedSqliteError(int error) { | 237 bool Connection::IsExpectedSqliteError(int error) { | 
| 238 if (!current_expecter_cb_) | 238 if (!current_expecter_cb_) | 
| 239 return false; | 239 return false; | 
| 240 return current_expecter_cb_->Run(error); | 240 return current_expecter_cb_->Run(error); | 
| 241 } | 241 } | 
| 242 | 242 | 
| 243 void Connection::ReportDiagnosticInfo(int extended_error, Statement* stmt) { | 243 void Connection::ReportDiagnosticInfo(int extended_error, Statement* stmt) { | 
| 244 AssertIOAllowed(); | 244 AssertIOAllowed(); | 
| 245 | 245 | 
| 246 // Trim extended error codes. | 246 std::string debug_info = GetDiagnosticInfo(extended_error, stmt); | 
| 
afakhry
2016/07/13 19:57:59
Note that this now will return debug info that con
 | |
| 247 const int error = (extended_error & 0xFF); | |
| 248 std::string debug_info; | |
| 249 if (error == SQLITE_CORRUPT) { | |
| 250 // CollectCorruptionInfo() is implemented in terms of sql::Connection, | |
| 251 // prevent reentrant calls to the error callback. | |
| 252 // TODO(shess): Rewrite IntegrityCheckHelper() in terms of raw SQLite. | |
| 253 ErrorCallback original_callback = std::move(error_callback_); | |
| 254 reset_error_callback(); | |
| 255 | |
| 256 debug_info = CollectCorruptionInfo(); | |
| 257 | |
| 258 error_callback_ = std::move(original_callback); | |
| 259 } else { | |
| 260 debug_info = CollectErrorInfo(extended_error, stmt); | |
| 261 } | |
| 262 | |
| 263 if (!debug_info.empty() && RegisterIntentToUpload()) { | 247 if (!debug_info.empty() && RegisterIntentToUpload()) { | 
| 264 char debug_buf[2000]; | 248 char debug_buf[2000]; | 
| 265 base::strlcpy(debug_buf, debug_info.c_str(), arraysize(debug_buf)); | 249 base::strlcpy(debug_buf, debug_info.c_str(), arraysize(debug_buf)); | 
| 266 base::debug::Alias(&debug_buf); | 250 base::debug::Alias(&debug_buf); | 
| 267 | 251 | 
| 268 base::debug::DumpWithoutCrashing(); | 252 base::debug::DumpWithoutCrashing(); | 
| 269 } | 253 } | 
| 270 } | 254 } | 
| 271 | 255 | 
| 272 // static | 256 // static | 
| (...skipping 1642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1915 return IntegrityCheckHelper("PRAGMA integrity_check", messages); | 1899 return IntegrityCheckHelper("PRAGMA integrity_check", messages); | 
| 1916 } | 1900 } | 
| 1917 | 1901 | 
| 1918 bool Connection::QuickIntegrityCheck() { | 1902 bool Connection::QuickIntegrityCheck() { | 
| 1919 std::vector<std::string> messages; | 1903 std::vector<std::string> messages; | 
| 1920 if (!IntegrityCheckHelper("PRAGMA quick_check", &messages)) | 1904 if (!IntegrityCheckHelper("PRAGMA quick_check", &messages)) | 
| 1921 return false; | 1905 return false; | 
| 1922 return messages.size() == 1 && messages[0] == "ok"; | 1906 return messages.size() == 1 && messages[0] == "ok"; | 
| 1923 } | 1907 } | 
| 1924 | 1908 | 
| 1909 std::string Connection::GetDiagnosticInfo(int extended_error, | |
| 1910 Statement* statement) { | |
| 1911 std::string result; | |
| 1912 const bool has_valid_header = | |
| 1913 (ExecuteAndReturnErrorCode("PRAGMA auto_vacuum") == SQLITE_OK); | |
| 1914 const bool select_sqlite_master_result = | |
| 1915 (ExecuteAndReturnErrorCode("SELECT COUNT(*) FROM sqlite_master") == | |
| 1916 SQLITE_OK); | |
| 1917 | |
| 1918 // Trim extended error codes. | |
| 1919 const int error = (extended_error & 0xFF); | |
| 1920 if (error == SQLITE_CORRUPT) { | |
| 1921 // CollectCorruptionInfo() is implemented in terms of sql::Connection, | |
| 1922 // prevent reentrant calls to the error callback. | |
| 1923 // TODO(shess): Rewrite IntegrityCheckHelper() in terms of raw SQLite. | |
| 1924 ErrorCallback original_callback = std::move(error_callback_); | |
| 1925 reset_error_callback(); | |
| 1926 | |
| 1927 result = CollectCorruptionInfo(); | |
| 
afakhry
2016/07/13 19:57:59
Another question to (shess | michaeln): Should we
 | |
| 1928 | |
| 1929 error_callback_ = std::move(original_callback); | |
| 1930 } else { | |
| 1931 result = CollectErrorInfo(extended_error, statement); | |
| 1932 } | |
| 1933 | |
| 1934 base::StringAppendF(&result, "Has valid header: %s\n", | |
| 1935 (has_valid_header ? "Yes" : "No")); | |
| 1936 base::StringAppendF(&result, "Has valid schema: %s\n", | |
| 1937 (select_sqlite_master_result ? "Yes" : "No")); | |
| 1938 | |
| 1939 return result; | |
| 1940 } | |
| 1941 | |
| 1925 // TODO(shess): Allow specifying maximum results (default 100 lines). | 1942 // TODO(shess): Allow specifying maximum results (default 100 lines). | 
| 1926 bool Connection::IntegrityCheckHelper( | 1943 bool Connection::IntegrityCheckHelper( | 
| 1927 const char* pragma_sql, | 1944 const char* pragma_sql, | 
| 1928 std::vector<std::string>* messages) { | 1945 std::vector<std::string>* messages) { | 
| 1929 messages->clear(); | 1946 messages->clear(); | 
| 1930 | 1947 | 
| 1931 // This has the side effect of setting SQLITE_RecoveryMode, which | 1948 // This has the side effect of setting SQLITE_RecoveryMode, which | 
| 1932 // allows SQLite to process through certain cases of corruption. | 1949 // allows SQLite to process through certain cases of corruption. | 
| 1933 // Failing to set this pragma probably means that the database is | 1950 // Failing to set this pragma probably means that the database is | 
| 1934 // beyond recovery. | 1951 // beyond recovery. | 
| (...skipping 21 matching lines...) Expand all Loading... | |
| 1956 ignore_result(Execute(kNoWritableSchema)); | 1973 ignore_result(Execute(kNoWritableSchema)); | 
| 1957 | 1974 | 
| 1958 return ret; | 1975 return ret; | 
| 1959 } | 1976 } | 
| 1960 | 1977 | 
| 1961 base::TimeTicks TimeSource::Now() { | 1978 base::TimeTicks TimeSource::Now() { | 
| 1962 return base::TimeTicks::Now(); | 1979 return base::TimeTicks::Now(); | 
| 1963 } | 1980 } | 
| 1964 | 1981 | 
| 1965 } // namespace sql | 1982 } // namespace sql | 
| OLD | NEW |