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

Side by Side Diff: chrome/browser/sync/glue/ui_model_worker.h

Issue 8366030: Introduce the plumbing necessary to report Unrecoverable error from model safe workers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: For try jobs. 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
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 #ifndef CHROME_BROWSER_SYNC_GLUE_UI_MODEL_WORKER_H_ 5 #ifndef CHROME_BROWSER_SYNC_GLUE_UI_MODEL_WORKER_H_
6 #define CHROME_BROWSER_SYNC_GLUE_UI_MODEL_WORKER_H_ 6 #define CHROME_BROWSER_SYNC_GLUE_UI_MODEL_WORKER_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/compiler_specific.h"
10 #include "base/synchronization/condition_variable.h" 11 #include "base/synchronization/condition_variable.h"
11 #include "base/synchronization/lock.h" 12 #include "base/synchronization/lock.h"
12 #include "base/task.h" 13 #include "base/task.h"
13 #include "chrome/browser/sync/engine/model_safe_worker.h" 14 #include "chrome/browser/sync/engine/model_safe_worker.h"
15 #include "chrome/browser/sync/util/unrecoverable_error_info.h"
14 16
15 namespace base { 17 namespace base {
16 class WaitableEvent; 18 class WaitableEvent;
17 } 19 }
18 20
19 class MessageLoop; 21 class MessageLoop;
20 22
21 namespace browser_sync { 23 namespace browser_sync {
22 24
23 // A ModelSafeWorker for UI models (e.g. bookmarks) that accepts work requests 25 // A ModelSafeWorker for UI models (e.g. bookmarks) that accepts work requests
24 // from the syncapi that need to be fulfilled from the MessageLoop home to the 26 // from the syncapi that need to be fulfilled from the MessageLoop home to the
25 // native model. 27 // native model.
26 // 28 //
27 // Lifetime note: Instances of this class will generally be owned by the 29 // Lifetime note: Instances of this class will generally be owned by the
28 // SyncerThread. When the SyncerThread _object_ is destroyed, the 30 // SyncerThread. When the SyncerThread _object_ is destroyed, the
29 // UIModelWorker will be destroyed. The SyncerThread object is destroyed 31 // UIModelWorker will be destroyed. The SyncerThread object is destroyed
30 // after the actual syncer pthread has exited. 32 // after the actual syncer pthread has exited.
31 class UIModelWorker : public browser_sync::ModelSafeWorker { 33 class UIModelWorker : public browser_sync::ModelSafeWorker {
32 public: 34 public:
33 UIModelWorker(); 35 UIModelWorker();
34 virtual ~UIModelWorker(); 36 virtual ~UIModelWorker();
35 37
36 // A simple task to signal a waitable event after Run()ning a Closure. 38 // A simple task to signal a waitable event after Run()ning a Closure.
37 class CallDoWorkAndSignalTask : public Task { 39 class CallDoWorkAndSignalTask : public Task {
38 public: 40 public:
39 CallDoWorkAndSignalTask(Callback0::Type* work, 41 CallDoWorkAndSignalTask(
40 base::WaitableEvent* work_done, 42 const WorkCallback& work,
41 UIModelWorker* scheduler) 43 base::WaitableEvent* work_done,
42 : work_(work), work_done_(work_done), scheduler_(scheduler) { 44 UIModelWorker* scheduler,
45 UnrecoverableErrorInfo* error_info)
46 : work_(work), work_done_(work_done), scheduler_(scheduler),
47 error_info_(error_info) {
43 } 48 }
44 virtual ~CallDoWorkAndSignalTask() { } 49 virtual ~CallDoWorkAndSignalTask() { }
45 50
46 // Task implementation. 51 // Task implementation.
47 virtual void Run(); 52 virtual void Run();
48 53
49 private: 54 private:
50 // Task data - a closure and a waitable event to signal after the work has 55 // Task data - a closure and a waitable event to signal after the work has
51 // been done. 56 // been done.
52 Callback0::Type* work_; 57 WorkCallback work_;
53 base::WaitableEvent* work_done_; 58 base::WaitableEvent* work_done_;
54 59
55 // The UIModelWorker responsible for scheduling us. 60 // The UIModelWorker responsible for scheduling us.
56 UIModelWorker* const scheduler_; 61 UIModelWorker* const scheduler_;
57 62
63 UnrecoverableErrorInfo* error_info_;
64
58 DISALLOW_COPY_AND_ASSIGN(CallDoWorkAndSignalTask); 65 DISALLOW_COPY_AND_ASSIGN(CallDoWorkAndSignalTask);
59 }; 66 };
60 67
61 // Called by the UI thread on shutdown of the sync service. Blocks until 68 // Called by the UI thread on shutdown of the sync service. Blocks until
62 // the UIModelWorker has safely met termination conditions, namely that 69 // the UIModelWorker has safely met termination conditions, namely that
63 // no task scheduled by CallDoWorkFromModelSafeThreadAndWait remains un- 70 // no task scheduled by CallDoWorkFromModelSafeThreadAndWait remains un-
64 // processed and that syncapi will not schedule any further work for us to do. 71 // processed and that syncapi will not schedule any further work for us to do.
65 void Stop(); 72 void Stop();
66 73
67 // ModelSafeWorker implementation. Called on syncapi SyncerThread. 74 // ModelSafeWorker implementation. Called on syncapi SyncerThread.
68 virtual void DoWorkAndWaitUntilDone(Callback0::Type* work); 75 virtual UnrecoverableErrorInfo DoWorkAndWaitUntilDone(
69 virtual ModelSafeGroup GetModelSafeGroup(); 76 const WorkCallback& work) OVERRIDE;
77 virtual ModelSafeGroup GetModelSafeGroup() OVERRIDE;
70 78
71 // Upon receiving this idempotent call, the ModelSafeWorker can 79 // Upon receiving this idempotent call, the ModelSafeWorker can
72 // assume no work will ever be scheduled again from now on. If it has any work 80 // assume no work will ever be scheduled again from now on. If it has any work
73 // that it has not yet completed, it must make sure to run it as soon as 81 // that it has not yet completed, it must make sure to run it as soon as
74 // possible as the Syncer is trying to shut down. Called from the CoreThread. 82 // possible as the Syncer is trying to shut down. Called from the CoreThread.
75 void OnSyncerShutdownComplete(); 83 void OnSyncerShutdownComplete();
76 84
77 // Callback from |pending_work_| to notify us that it has been run. 85 // Callback from |pending_work_| to notify us that it has been run.
78 // Called on ui loop. 86 // Called on ui loop.
79 void OnTaskCompleted() { pending_work_ = NULL; } 87 void OnTaskCompleted() { pending_work_ = NULL; }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 // SyncerThread has terminated. We only care about (1) when we are in Stop(), 130 // SyncerThread has terminated. We only care about (1) when we are in Stop(),
123 // because we have to manually Run() the task. 131 // because we have to manually Run() the task.
124 base::ConditionVariable syncapi_event_; 132 base::ConditionVariable syncapi_event_;
125 133
126 DISALLOW_COPY_AND_ASSIGN(UIModelWorker); 134 DISALLOW_COPY_AND_ASSIGN(UIModelWorker);
127 }; 135 };
128 136
129 } // namespace browser_sync 137 } // namespace browser_sync
130 138
131 #endif // CHROME_BROWSER_SYNC_GLUE_UI_MODEL_WORKER_H_ 139 #endif // CHROME_BROWSER_SYNC_GLUE_UI_MODEL_WORKER_H_
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/password_model_worker.cc ('k') | chrome/browser/sync/glue/ui_model_worker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698