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

Side by Side Diff: chrome/browser/history/thumbnail_database.cc

Issue 270101: Move the sqlite error handler to a single location... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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 | Annotate | Revision Log
OLDNEW
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/history/thumbnail_database.h" 5 #include "chrome/browser/history/thumbnail_database.h"
6 6
7 #include "app/gfx/codec/jpeg_codec.h" 7 #include "app/gfx/codec/jpeg_codec.h"
8 #include "app/sql/statement.h" 8 #include "app/sql/statement.h"
9 #include "app/sql/transaction.h" 9 #include "app/sql/transaction.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/time.h" 11 #include "base/time.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "chrome/browser/diagnostics/sqlite_diagnostics.h"
13 #include "chrome/browser/history/history_publisher.h" 14 #include "chrome/browser/history/history_publisher.h"
14 #include "chrome/browser/history/url_database.h" 15 #include "chrome/browser/history/url_database.h"
15 #include "chrome/common/thumbnail_score.h" 16 #include "chrome/common/thumbnail_score.h"
16 #include "third_party/skia/include/core/SkBitmap.h" 17 #include "third_party/skia/include/core/SkBitmap.h"
17 18
18 namespace history { 19 namespace history {
19 20
20 // Version number of the database. 21 // Version number of the database.
21 static const int kCurrentVersionNumber = 3; 22 static const int kCurrentVersionNumber = 3;
22 static const int kCompatibleVersionNumber = 3; 23 static const int kCompatibleVersionNumber = 3;
23 24
24 ThumbnailDatabase::ThumbnailDatabase() : history_publisher_(NULL) { 25 ThumbnailDatabase::ThumbnailDatabase() : history_publisher_(NULL) {
25 } 26 }
26 27
27 ThumbnailDatabase::~ThumbnailDatabase() { 28 ThumbnailDatabase::~ThumbnailDatabase() {
28 // The DBCloseScoper will delete the DB and the cache. 29 // The DBCloseScoper will delete the DB and the cache.
29 } 30 }
30 31
31 InitStatus ThumbnailDatabase::Init(const FilePath& db_name, 32 InitStatus ThumbnailDatabase::Init(const FilePath& db_name,
32 const HistoryPublisher* history_publisher) { 33 const HistoryPublisher* history_publisher) {
33 history_publisher_ = history_publisher; 34 history_publisher_ = history_publisher;
34 35
36 // Set the exceptional sqlite error handler.
37 db_.set_error_delegate(GetErrorHandlerForThumbnailDb());
38
35 // Set the database page size to something larger to give us 39 // Set the database page size to something larger to give us
36 // better performance (we're typically seek rather than bandwidth limited). 40 // better performance (we're typically seek rather than bandwidth limited).
37 // This only has an effect before any tables have been created, otherwise 41 // This only has an effect before any tables have been created, otherwise
38 // this is a NOP. Must be a power of 2 and a max of 8192. We use a bigger 42 // this is a NOP. Must be a power of 2 and a max of 8192. We use a bigger
39 // one because we're storing larger data (4-16K) in it, so we want a few 43 // one because we're storing larger data (4-16K) in it, so we want a few
40 // blocks per element. 44 // blocks per element.
41 db_.set_page_size(4096); 45 db_.set_page_size(4096);
42 46
43 // The UI is generally designed to work well when the thumbnail database is 47 // The UI is generally designed to work well when the thumbnail database is
44 // slow, so we can tolerate much less caching. The file is also very large 48 // slow, so we can tolerate much less caching. The file is also very large
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 // Rename the temporary one. 436 // Rename the temporary one.
433 if (!db_.Execute("ALTER TABLE temp_favicons RENAME TO favicons")) 437 if (!db_.Execute("ALTER TABLE temp_favicons RENAME TO favicons"))
434 return false; 438 return false;
435 439
436 // The renamed table needs the index (the temporary table doesn't have one). 440 // The renamed table needs the index (the temporary table doesn't have one).
437 InitFavIconsIndex(); 441 InitFavIconsIndex();
438 return true; 442 return true;
439 } 443 }
440 444
441 } // namespace history 445 } // namespace history
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698