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

Side by Side Diff: sql/connection.cc

Issue 2107493002: Offer user to send feedback from profile error dialog (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: wchar_t Created 4 years, 5 months 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
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 <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 1904 matching lines...) Expand 10 before | Expand all | Expand 10 after
1915 return IntegrityCheckHelper("PRAGMA integrity_check", messages); 1915 return IntegrityCheckHelper("PRAGMA integrity_check", messages);
1916 } 1916 }
1917 1917
1918 bool Connection::QuickIntegrityCheck() { 1918 bool Connection::QuickIntegrityCheck() {
1919 std::vector<std::string> messages; 1919 std::vector<std::string> messages;
1920 if (!IntegrityCheckHelper("PRAGMA quick_check", &messages)) 1920 if (!IntegrityCheckHelper("PRAGMA quick_check", &messages))
1921 return false; 1921 return false;
1922 return messages.size() == 1 && messages[0] == "ok"; 1922 return messages.size() == 1 && messages[0] == "ok";
1923 } 1923 }
1924 1924
1925 sql::DatabaseDiagnosticMap Connection::GetDiagnosticMap() {
1926 sql::DatabaseDiagnosticMap result;
1927 const bool has_valid_header =
1928 (ExecuteAndReturnErrorCode("PRAGMA auto_vacuum") == SQLITE_OK);
1929 const bool select_sqlite_master_result =
1930 (ExecuteAndReturnErrorCode("SELECT COUNT(*) FROM sqlite_master") ==
1931 SQLITE_OK);
1932
1933 // If any of the above failed, that's an indication that the file is really
1934 // corrupted. Doing the integrity check or getting the schema will crash on
1935 // DCHECKs on debug builds.
1936 std::string integrity_check_result("Failed");
1937 std::string schema("Failed");
1938 if (has_valid_header && select_sqlite_master_result) {
1939 std::vector<std::string> integrity_check_output;
1940 if (FullIntegrityCheck(&integrity_check_output)) {
1941 // we can only get the schema if the integrity check passes.
1942 integrity_check_result = "Success";
1943 schema = GetSchema();
1944 }
1945 for (const auto& line : integrity_check_output)
1946 integrity_check_result += "\n\t" + line;
1947 }
1948
1949 result["Has valid header"] = has_valid_header ? "Yes" : "No";
1950 result["Master table exists"] = select_sqlite_master_result ? "Yes" : "No";
1951 result["Integrity check"] = integrity_check_result;
1952 result["Schema"] = schema;
1953
1954 return result;
1955 }
1956
1925 // TODO(shess): Allow specifying maximum results (default 100 lines). 1957 // TODO(shess): Allow specifying maximum results (default 100 lines).
1926 bool Connection::IntegrityCheckHelper( 1958 bool Connection::IntegrityCheckHelper(
1927 const char* pragma_sql, 1959 const char* pragma_sql,
1928 std::vector<std::string>* messages) { 1960 std::vector<std::string>* messages) {
1929 messages->clear(); 1961 messages->clear();
1930 1962
1931 // This has the side effect of setting SQLITE_RecoveryMode, which 1963 // This has the side effect of setting SQLITE_RecoveryMode, which
1932 // allows SQLite to process through certain cases of corruption. 1964 // allows SQLite to process through certain cases of corruption.
1933 // Failing to set this pragma probably means that the database is 1965 // Failing to set this pragma probably means that the database is
1934 // beyond recovery. 1966 // beyond recovery.
(...skipping 21 matching lines...) Expand all
1956 ignore_result(Execute(kNoWritableSchema)); 1988 ignore_result(Execute(kNoWritableSchema));
1957 1989
1958 return ret; 1990 return ret;
1959 } 1991 }
1960 1992
1961 base::TimeTicks TimeSource::Now() { 1993 base::TimeTicks TimeSource::Now() {
1962 return base::TimeTicks::Now(); 1994 return base::TimeTicks::Now();
1963 } 1995 }
1964 1996
1965 } // namespace sql 1997 } // namespace sql
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698