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

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

Issue 8631002: [ntp4] Use highest quality jpeg compression for thumbnail images. (Closed) Base URL: svn://svn.chromium.org/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 | chrome/browser/history/top_sites.cc » ('j') | ui/gfx/image/image_util.h » ('J')
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 "chrome/browser/history/thumbnail_database.h" 5 #include "chrome/browser/history/thumbnail_database.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 24 matching lines...) Expand all
35 static_cast<history::IconType>(statement.ColumnInt(2)); 35 static_cast<history::IconType>(statement.ColumnInt(2));
36 icon_mapping->page_url = page_url; 36 icon_mapping->page_url = page_url;
37 } 37 }
38 38
39 namespace history { 39 namespace history {
40 40
41 // Version number of the database. 41 // Version number of the database.
42 static const int kCurrentVersionNumber = 5; 42 static const int kCurrentVersionNumber = 5;
43 static const int kCompatibleVersionNumber = 5; 43 static const int kCompatibleVersionNumber = 5;
44 44
45 // Use 90 quality (out of 100) which is pretty high, because we're very
46 // sensitive to artifacts for these small sized, highly detailed images.
47 static const int kImageQuality = 90;
48
45 ThumbnailDatabase::ThumbnailDatabase() 49 ThumbnailDatabase::ThumbnailDatabase()
46 : history_publisher_(NULL), 50 : history_publisher_(NULL),
47 use_top_sites_(false) { 51 use_top_sites_(false) {
48 } 52 }
49 53
50 sql::InitStatus ThumbnailDatabase::CantUpgradeToVersion(int cur_version) { 54 sql::InitStatus ThumbnailDatabase::CantUpgradeToVersion(int cur_version) {
51 LOG(WARNING) << "Unable to update to thumbnail database to version 4" << 55 LOG(WARNING) << "Unable to update to thumbnail database to version 4" <<
52 cur_version << "."; 56 cur_version << ".";
53 db_.Close(); 57 db_.Close();
54 return sql::INIT_FAILURE; 58 return sql::INIT_FAILURE;
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 259
256 if (add_thumbnail) { 260 if (add_thumbnail) {
257 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, 261 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE,
258 "INSERT OR REPLACE INTO thumbnails " 262 "INSERT OR REPLACE INTO thumbnails "
259 "(url_id, boring_score, good_clipping, at_top, last_updated, data) " 263 "(url_id, boring_score, good_clipping, at_top, last_updated, data) "
260 "VALUES (?,?,?,?,?,?)")); 264 "VALUES (?,?,?,?,?,?)"));
261 if (!statement) 265 if (!statement)
262 return; 266 return;
263 267
264 std::vector<unsigned char> jpeg_data; 268 std::vector<unsigned char> jpeg_data;
265 bool encoded = gfx::JPEGEncodedDataFromImage(*thumbnail, &jpeg_data); 269 bool encoded = gfx::JPEGEncodedDataFromImage(*thumbnail, kImageQuality,
270 &jpeg_data);
266 if (encoded) { 271 if (encoded) {
267 statement.BindInt64(0, id); 272 statement.BindInt64(0, id);
268 statement.BindDouble(1, score.boring_score); 273 statement.BindDouble(1, score.boring_score);
269 statement.BindBool(2, score.good_clipping); 274 statement.BindBool(2, score.good_clipping);
270 statement.BindBool(3, score.at_top); 275 statement.BindBool(3, score.at_top);
271 statement.BindInt64(4, score.time_at_snapshot.ToTimeT()); 276 statement.BindInt64(4, score.time_at_snapshot.ToTimeT());
272 statement.BindBlob(5, &jpeg_data[0], 277 statement.BindBlob(5, &jpeg_data[0],
273 static_cast<int>(jpeg_data.size())); 278 static_cast<int>(jpeg_data.size()));
274 if (!statement.Run()) 279 if (!statement.Run())
275 NOTREACHED() << db_.GetErrorMessage(); 280 NOTREACHED() << db_.GetErrorMessage();
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 if (!db_.Execute("ALTER TABLE favicons ADD sizes LONGVARCHAR")) { 784 if (!db_.Execute("ALTER TABLE favicons ADD sizes LONGVARCHAR")) {
780 NOTREACHED(); 785 NOTREACHED();
781 return false; 786 return false;
782 } 787 }
783 meta_table_.SetVersionNumber(5); 788 meta_table_.SetVersionNumber(5);
784 meta_table_.SetCompatibleVersionNumber(std::min(5, kCompatibleVersionNumber)); 789 meta_table_.SetCompatibleVersionNumber(std::min(5, kCompatibleVersionNumber));
785 return true; 790 return true;
786 } 791 }
787 792
788 } // namespace history 793 } // namespace history
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/history/top_sites.cc » ('j') | ui/gfx/image/image_util.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698