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: webkit/quota/quota_database.cc

Issue 8341123: Setup the error delegate for the quota database so we get error histograms. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "webkit/quota/quota_database.h" 5 #include "webkit/quota/quota_database.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 17 matching lines...) Expand all
28 28
29 const char kHostQuotaTable[] = "HostQuotaTable"; 29 const char kHostQuotaTable[] = "HostQuotaTable";
30 const char kOriginInfoTable[] = "OriginInfoTable"; 30 const char kOriginInfoTable[] = "OriginInfoTable";
31 const char kIsOriginTableBootstrapped[] = "IsOriginTableBootstrapped"; 31 const char kIsOriginTableBootstrapped[] = "IsOriginTableBootstrapped";
32 32
33 class HistogramUniquifier { 33 class HistogramUniquifier {
34 public: 34 public:
35 static const char* name() { return "Sqlite.Quota.Error"; } 35 static const char* name() { return "Sqlite.Quota.Error"; }
36 }; 36 };
37 37
38 sql::ErrorDelegate* GetErrorHandlerForQuotaDb() {
39 return new sql::DiagnosticErrorDelegate<HistogramUniquifier>();
40 }
41
38 bool PrepareCachedStatement( 42 bool PrepareCachedStatement(
39 sql::Connection* db, const sql::StatementID& id, 43 sql::Connection* db, const sql::StatementID& id,
40 const char* sql, sql::Statement* statement) { 44 const char* sql, sql::Statement* statement) {
41 DCHECK(db && sql && statement); 45 DCHECK(db && sql && statement);
42 statement->Assign(db->GetCachedStatement(id, sql)); 46 statement->Assign(db->GetCachedStatement(id, sql));
43 if (!statement->is_valid()) { 47 if (!statement->is_valid()) {
44 NOTREACHED() << db->GetErrorMessage(); 48 NOTREACHED() << db->GetErrorMessage();
45 return false; 49 return false;
46 } 50 }
47 return true; 51 return true;
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 474
471 bool in_memory_only = db_file_path_.empty(); 475 bool in_memory_only = db_file_path_.empty();
472 if (!create_if_needed && 476 if (!create_if_needed &&
473 (in_memory_only || !file_util::PathExists(db_file_path_))) { 477 (in_memory_only || !file_util::PathExists(db_file_path_))) {
474 return false; 478 return false;
475 } 479 }
476 480
477 db_.reset(new sql::Connection); 481 db_.reset(new sql::Connection);
478 meta_table_.reset(new sql::MetaTable); 482 meta_table_.reset(new sql::MetaTable);
479 483
484 db_->set_error_delegate(GetErrorHandlerForQuotaDb());
485
480 bool opened = false; 486 bool opened = false;
481 if (in_memory_only) { 487 if (in_memory_only) {
482 opened = db_->OpenInMemory(); 488 opened = db_->OpenInMemory();
483 } else if (!file_util::CreateDirectory(db_file_path_.DirName())) { 489 } else if (!file_util::CreateDirectory(db_file_path_.DirName())) {
484 LOG(ERROR) << "Failed to create quota database directory."; 490 LOG(ERROR) << "Failed to create quota database directory.";
485 } else { 491 } else {
486 opened = db_->Open(db_file_path_); 492 opened = db_->Open(db_file_path_);
487 if (opened) 493 if (opened)
488 db_->Preload(); 494 db_->Preload();
489 } 495 }
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 if (lhs.origin < rhs.origin) return true; 690 if (lhs.origin < rhs.origin) return true;
685 if (rhs.origin < lhs.origin) return false; 691 if (rhs.origin < lhs.origin) return false;
686 if (lhs.type < rhs.type) return true; 692 if (lhs.type < rhs.type) return true;
687 if (rhs.type < lhs.type) return false; 693 if (rhs.type < lhs.type) return false;
688 if (lhs.used_count < rhs.used_count) return true; 694 if (lhs.used_count < rhs.used_count) return true;
689 if (rhs.used_count < lhs.used_count) return false; 695 if (rhs.used_count < lhs.used_count) return false;
690 return lhs.last_access_time < rhs.last_access_time; 696 return lhs.last_access_time < rhs.last_access_time;
691 } 697 }
692 698
693 } // quota namespace 699 } // quota namespace
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698