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

Side by Side Diff: chrome/browser/thumbnail_store.cc

Issue 255081: Coverity: Allocate |cache| after we have a logic path where we can return and... (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
« 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) 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/thumbnail_store.h" 5 #include "chrome/browser/thumbnail_store.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 #include <algorithm> 8 #include <algorithm>
9 9
10 #include "app/gfx/codec/jpeg_codec.h" 10 #include "app/gfx/codec/jpeg_codec.h"
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 "time_taken INTEGER DEFAULT 0," 363 "time_taken INTEGER DEFAULT 0,"
364 "data BLOB)")) 364 "data BLOB)"))
365 return; 365 return;
366 } 366 }
367 367
368 if (cb_loop) 368 if (cb_loop)
369 GetAllThumbnailsFromDisk(cb_loop); 369 GetAllThumbnailsFromDisk(cb_loop);
370 } 370 }
371 371
372 void ThumbnailStore::GetAllThumbnailsFromDisk(MessageLoop* cb_loop) { 372 void ThumbnailStore::GetAllThumbnailsFromDisk(MessageLoop* cb_loop) {
373 Cache* cache = new Cache;
374
375 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, 373 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE,
376 "SELECT * FROM thumbnails")); 374 "SELECT * FROM thumbnails"));
377 if (!statement) 375 if (!statement)
378 return; 376 return;
379 377
378 Cache* cache = new Cache;
380 while (statement.Step()) { 379 while (statement.Step()) {
381 // The URL 380 // The URL
382 GURL url(statement.ColumnString(0)); 381 GURL url(statement.ColumnString(0));
383 382
384 // The score. 383 // The score.
385 ThumbnailScore score(statement.ColumnDouble(1), // Boring score 384 ThumbnailScore score(statement.ColumnDouble(1), // Boring score
386 statement.ColumnBool(2), // Good clipping 385 statement.ColumnBool(2), // Good clipping
387 statement.ColumnBool(3), // At top 386 statement.ColumnBool(3), // At top
388 base::Time::FromInternalValue( 387 base::Time::FromInternalValue(
389 statement.ColumnInt64(4))); // Time taken 388 statement.ColumnInt64(4))); // Time taken
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 424
426 std::wstring ThumbnailStore::GetDictionaryKeyForURL( 425 std::wstring ThumbnailStore::GetDictionaryKeyForURL(
427 const std::string& url) const { 426 const std::string& url) const {
428 return ASCIIToWide(MD5String(url)); 427 return ASCIIToWide(MD5String(url));
429 } 428 }
430 429
431 bool ThumbnailStore::IsPopular(const GURL& url) const { 430 bool ThumbnailStore::IsPopular(const GURL& url) const {
432 return most_visited_urls_->size() < kMaxCacheSize || 431 return most_visited_urls_->size() < kMaxCacheSize ||
433 most_visited_urls_->find(url) != most_visited_urls_->end(); 432 most_visited_urls_->find(url) != most_visited_urls_->end();
434 } 433 }
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