summaryrefslogtreecommitdiffstats
path: root/chrome/browser/bookmarks/bookmark_storage.cc
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-02 05:59:37 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-02 05:59:37 +0000
commit6fad26338ed6119903826156f307e20fe6657c31 (patch)
tree5c6baed35fce907a0cea47ed6091c941db8ebfd1 /chrome/browser/bookmarks/bookmark_storage.cc
parentf75c8f13b967b01babc9454506e9d2ed00519e39 (diff)
downloadchromium_src-6fad26338ed6119903826156f307e20fe6657c31.zip
chromium_src-6fad26338ed6119903826156f307e20fe6657c31.tar.gz
chromium_src-6fad26338ed6119903826156f307e20fe6657c31.tar.bz2
Third patch in getting rid of caching MessageLoop pointers and always using ChromeThread instead.
BUG=25354 Review URL: http://codereview.chromium.org/342068 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30687 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/bookmarks/bookmark_storage.cc')
-rw-r--r--chrome/browser/bookmarks/bookmark_storage.cc45
1 files changed, 13 insertions, 32 deletions
diff --git a/chrome/browser/bookmarks/bookmark_storage.cc b/chrome/browser/bookmarks/bookmark_storage.cc
index 10f79ff..387fa71 100644
--- a/chrome/browser/bookmarks/bookmark_storage.cc
+++ b/chrome/browser/bookmarks/bookmark_storage.cc
@@ -7,12 +7,10 @@
#include "base/compiler_specific.h"
#include "base/file_util.h"
#include "base/histogram.h"
-#include "base/message_loop.h"
-#include "base/thread.h"
#include "base/time.h"
#include "chrome/browser/bookmarks/bookmark_codec.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
-#include "chrome/browser/browser_process.h"
+#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/profile.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/json_value_serializer.h"
@@ -65,11 +63,9 @@ class FileDeleteTask : public Task {
class BookmarkStorage::LoadTask : public Task {
public:
LoadTask(const FilePath& path,
- MessageLoop* loop,
BookmarkStorage* storage,
LoadDetails* details)
: path_(path),
- loop_(loop),
storage_(storage),
details_(details) {
}
@@ -103,13 +99,11 @@ class BookmarkStorage::LoadTask : public Task {
}
}
- if (loop_) {
- loop_->PostTask(FROM_HERE, NewRunnableMethod(
- storage_.get(), &BookmarkStorage::OnLoadFinished,
- bookmark_file_exists, path_));
- } else {
- storage_->OnLoadFinished(bookmark_file_exists, path_);
- }
+ ChromeThread::PostTask(
+ ChromeThread::UI, FROM_HERE,
+ NewRunnableMethod(
+ storage_.get(), &BookmarkStorage::OnLoadFinished,
+ bookmark_file_exists, path_));
}
private:
@@ -125,7 +119,6 @@ class BookmarkStorage::LoadTask : public Task {
}
const FilePath path_;
- MessageLoop* loop_;
scoped_refptr<BookmarkStorage> storage_;
LoadDetails* details_;
@@ -137,13 +130,12 @@ class BookmarkStorage::LoadTask : public Task {
BookmarkStorage::BookmarkStorage(Profile* profile, BookmarkModel* model)
: profile_(profile),
model_(model),
- backend_thread_(g_browser_process->file_thread()),
- writer_(profile->GetPath().Append(chrome::kBookmarksFileName),
- backend_thread_),
+ writer_(profile->GetPath().Append(chrome::kBookmarksFileName)),
tmp_history_path_(
profile->GetPath().Append(chrome::kHistoryBookmarksFileName)) {
writer_.set_commit_interval(base::TimeDelta::FromMilliseconds(kSaveDelayMS));
- RunTaskOnBackendThread(new BackupTask(writer_.path()));
+ ChromeThread::PostTask(
+ ChromeThread::FILE, FROM_HERE, new BackupTask(writer_.path()));
}
BookmarkStorage::~BookmarkStorage() {
@@ -159,11 +151,8 @@ void BookmarkStorage::LoadBookmarks(LoadDetails* details) {
}
void BookmarkStorage::DoLoadBookmarks(const FilePath& path) {
- Task* task = new LoadTask(path,
- backend_thread() ? MessageLoop::current() : NULL,
- this,
- details_.get());
- RunTaskOnBackendThread(task);
+ ChromeThread::PostTask(
+ ChromeThread::FILE, FROM_HERE, new LoadTask(path, this, details_.get()));
}
void BookmarkStorage::MigrateFromHistory() {
@@ -238,7 +227,8 @@ void BookmarkStorage::OnLoadFinished(bool file_exists, const FilePath& path) {
SaveNow();
// Clean up after migration from history.
- RunTaskOnBackendThread(new FileDeleteTask(tmp_history_path_));
+ ChromeThread::PostTask(
+ ChromeThread::FILE, FROM_HERE, new FileDeleteTask(tmp_history_path_));
}
}
@@ -270,12 +260,3 @@ bool BookmarkStorage::SaveNow() {
writer_.WriteNow(data);
return true;
}
-
-void BookmarkStorage::RunTaskOnBackendThread(Task* task) const {
- if (backend_thread()) {
- backend_thread()->message_loop()->PostTask(FROM_HERE, task);
- } else {
- task->Run();
- delete task;
- }
-}