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

Side by Side Diff: chrome/browser/sync/glue/history_model_worker.cc

Issue 9036003: Avoid useless SYNC_CYCLE_CONTINUATION sync cycle (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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) 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/sync/glue/history_model_worker.h" 5 #include "chrome/browser/sync/glue/history_model_worker.h"
6 6
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/synchronization/waitable_event.h" 9 #include "base/synchronization/waitable_event.h"
10 #include "chrome/browser/history/history.h" 10 #include "chrome/browser/history/history.h"
11 11
12 using base::WaitableEvent; 12 using base::WaitableEvent;
13 13
14 namespace browser_sync { 14 namespace browser_sync {
15 15
16 class WorkerTask : public HistoryDBTask { 16 class WorkerTask : public HistoryDBTask {
17 public: 17 public:
18 WorkerTask( 18 WorkerTask(
19 const WorkCallback& work, 19 const WorkCallback& work,
20 WaitableEvent* done, 20 WaitableEvent* done,
21 UnrecoverableErrorInfo* error_info) 21 SyncerError* error)
22 : work_(work), done_(done), error_info_(error_info) {} 22 : work_(work), done_(done), error_(error) {}
23 23
24 virtual bool RunOnDBThread(history::HistoryBackend* backend, 24 virtual bool RunOnDBThread(history::HistoryBackend* backend,
25 history::HistoryDatabase* db) { 25 history::HistoryDatabase* db) {
26 *error_info_ = work_.Run(); 26 *error_ = work_.Run();
27 done_->Signal(); 27 done_->Signal();
28 return true; 28 return true;
29 } 29 }
30 30
31 // Since the DoWorkAndWaitUntilDone() is syncronous, we don't need to run any 31 // Since the DoWorkAndWaitUntilDone() is syncronous, we don't need to run any
32 // code asynchronously on the main thread after completion. 32 // code asynchronously on the main thread after completion.
33 virtual void DoneRunOnMainThread() {} 33 virtual void DoneRunOnMainThread() {}
34 34
35 protected: 35 protected:
36 WorkCallback work_; 36 WorkCallback work_;
37 WaitableEvent* done_; 37 WaitableEvent* done_;
38 UnrecoverableErrorInfo* error_info_; 38 SyncerError* error_;
39 }; 39 };
40 40
41 41
42 HistoryModelWorker::HistoryModelWorker(HistoryService* history_service) 42 HistoryModelWorker::HistoryModelWorker(HistoryService* history_service)
43 : history_service_(history_service) { 43 : history_service_(history_service) {
44 CHECK(history_service); 44 CHECK(history_service);
45 } 45 }
46 46
47 HistoryModelWorker::~HistoryModelWorker() { 47 HistoryModelWorker::~HistoryModelWorker() {
48 } 48 }
49 49
50 UnrecoverableErrorInfo HistoryModelWorker::DoWorkAndWaitUntilDone( 50 SyncerError HistoryModelWorker::DoWorkAndWaitUntilDone(
51 const WorkCallback& work) { 51 const WorkCallback& work) {
52 WaitableEvent done(false, false); 52 WaitableEvent done(false, false);
53 UnrecoverableErrorInfo error_info; 53 SyncerError error = UNINITIALIZED;
54 scoped_refptr<WorkerTask> task(new WorkerTask(work, &done, &error_info)); 54 scoped_refptr<WorkerTask> task(new WorkerTask(work, &done, &error));
55 history_service_->ScheduleDBTask(task.get(), &cancelable_consumer_); 55 history_service_->ScheduleDBTask(task.get(), &cancelable_consumer_);
56 done.Wait(); 56 done.Wait();
57 return error_info; 57 return error;
58 } 58 }
59 59
60 ModelSafeGroup HistoryModelWorker::GetModelSafeGroup() { 60 ModelSafeGroup HistoryModelWorker::GetModelSafeGroup() {
61 return GROUP_HISTORY; 61 return GROUP_HISTORY;
62 } 62 }
63 63
64 } // namespace browser_sync 64 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/history_model_worker.h ('k') | chrome/browser/sync/glue/password_model_worker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698