summaryrefslogtreecommitdiffstats
path: root/chrome/browser/dom_ui
diff options
context:
space:
mode:
authormeelapshah@chromium.org <meelapshah@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-03 00:49:13 +0000
committermeelapshah@chromium.org <meelapshah@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-03 00:49:13 +0000
commite06b82b5e14a184fca588aa880d0f634b92337d5 (patch)
treecd04b78988b2ddcd734c5f3a024c4d62c5ec256a /chrome/browser/dom_ui
parentd72a267b170795b5bd8d418e3d382349583beb15 (diff)
downloadchromium_src-e06b82b5e14a184fca588aa880d0f634b92337d5.zip
chromium_src-e06b82b5e14a184fca588aa880d0f634b92337d5.tar.gz
chromium_src-e06b82b5e14a184fca588aa880d0f634b92337d5.tar.bz2
Modify ThumbnailStore to make one call to the HistoryBackend using QueryTopURLsAndRedirects instead of a seperate call for each URL. Also clean up some of the code and fix bug 14644.
BUG=14644 TEST=none Review URL: http://codereview.chromium.org/149126 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19879 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/dom_ui')
-rw-r--r--chrome/browser/dom_ui/dom_ui_thumbnail_source.cc31
-rw-r--r--chrome/browser/dom_ui/dom_ui_thumbnail_source.h9
2 files changed, 2 insertions, 38 deletions
diff --git a/chrome/browser/dom_ui/dom_ui_thumbnail_source.cc b/chrome/browser/dom_ui/dom_ui_thumbnail_source.cc
index c3d51a1..fd40e867 100644
--- a/chrome/browser/dom_ui/dom_ui_thumbnail_source.cc
+++ b/chrome/browser/dom_ui/dom_ui_thumbnail_source.cc
@@ -21,20 +21,15 @@ DOMUIThumbnailSource::DOMUIThumbnailSource(Profile* profile)
store_(profile->GetThumbnailStore()) {
}
-DOMUIThumbnailSource::~DOMUIThumbnailSource() {
- store_->CancelPendingRequests(pending_requests_);
-}
-
void DOMUIThumbnailSource::StartDataRequest(const std::string& path,
int request_id) {
if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kThumbnailStore)) {
RefCountedBytes* data = NULL;
- ThumbnailStore::GetStatus res = store_->GetPageThumbnail(GURL(path), &data);
- if (res == ThumbnailStore::SUCCESS) {
+ if (store_->GetPageThumbnail(GURL(path), &data)) {
// Got the thumbnail.
SendResponse(request_id, data);
- } else if (res == ThumbnailStore::FAIL) {
+ } else {
// Don't have the thumbnail so return the default thumbnail.
if (!default_thumbnail_.get()) {
default_thumbnail_ = new RefCountedBytes;
@@ -42,12 +37,6 @@ void DOMUIThumbnailSource::StartDataRequest(const std::string& path,
IDR_DEFAULT_THUMBNAIL, &default_thumbnail_->data);
}
SendResponse(request_id, default_thumbnail_);
- } else if (res == ThumbnailStore::ASYNC) {
- // Getting the redirect list for the url. Will return thumbnail later.
- ThumbnailStore::ThumbnailDataCallback* cb =
- NewCallback(this, &DOMUIThumbnailSource::ReturnData);
- pending_requests_.insert(request_id);
- store_->GetPageThumbnailAsync(GURL(path), request_id, cb);
}
return;
} // end --thumbnail-store switch
@@ -66,22 +55,6 @@ void DOMUIThumbnailSource::StartDataRequest(const std::string& path,
}
}
-void DOMUIThumbnailSource::ReturnData(int request_id,
- scoped_refptr<RefCountedBytes> data) {
- pending_requests_.erase(request_id);
- if (data.get() && !data->data.empty()) {
- SendResponse(request_id, data);
- } else {
- if (!default_thumbnail_.get()) {
- default_thumbnail_ = new RefCountedBytes;
- ResourceBundle::GetSharedInstance().LoadImageResourceBytes(
- IDR_DEFAULT_THUMBNAIL, &default_thumbnail_->data);
- }
-
- SendResponse(request_id, default_thumbnail_);
- }
-}
-
void DOMUIThumbnailSource::OnThumbnailDataAvailable(
HistoryService::Handle request_handle,
scoped_refptr<RefCountedBytes> data) {
diff --git a/chrome/browser/dom_ui/dom_ui_thumbnail_source.h b/chrome/browser/dom_ui/dom_ui_thumbnail_source.h
index b694466..2d475af 100644
--- a/chrome/browser/dom_ui/dom_ui_thumbnail_source.h
+++ b/chrome/browser/dom_ui/dom_ui_thumbnail_source.h
@@ -21,17 +21,11 @@ class ThumbnailStore;
class DOMUIThumbnailSource : public ChromeURLDataManager::DataSource {
public:
explicit DOMUIThumbnailSource(Profile* profile);
- virtual ~DOMUIThumbnailSource();
// Called when the network layer has requested a resource underneath
// the path we registered.
virtual void StartDataRequest(const std::string& path, int request_id);
- // Used only when chromium is invoked with the --thumbnail-store switch.
- // If StartDataRequest does not return thumbnail data synchronously, this
- // method will be invoked when the thumbnail data becomes available.
- virtual void ReturnData(int request_id, scoped_refptr<RefCountedBytes> data);
-
virtual std::string GetMimeType(const std::string&) const {
// We need to explicitly return a mime type, otherwise if the user tries to
// drag the image they get no extension.
@@ -46,9 +40,6 @@ class DOMUIThumbnailSource : public ChromeURLDataManager::DataSource {
Profile* profile_;
CancelableRequestConsumerT<int, 0> cancelable_consumer_;
- // A set of outstanding request_id's. These are canceled on destruction.
- std::set<int> pending_requests_;
-
// The ThumbnailStore from which thumbnails are requested.
scoped_refptr<ThumbnailStore> store_;