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

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

Issue 7041008: Moved ScopeStopObserving to a template class in change_processor.h. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleaned up long line. Created 9 years, 6 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 | « chrome/browser/sync/glue/autofill_profile_change_processor.cc ('k') | 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) 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_CHANGE_PROCESSOR_H_ 5 #ifndef CHROME_BROWSER_SYNC_GLUE_CHANGE_PROCESSOR_H_
6 #define CHROME_BROWSER_SYNC_GLUE_CHANGE_PROCESSOR_H_ 6 #define CHROME_BROWSER_SYNC_GLUE_CHANGE_PROCESSOR_H_
7 #pragma once 7 #pragma once
8 8
9 #include "chrome/browser/sync/engine/syncapi.h" 9 #include "chrome/browser/sync/engine/syncapi.h"
10 #include "chrome/browser/sync/glue/sync_backend_host.h" 10 #include "chrome/browser/sync/glue/sync_backend_host.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 // The changes found in ApplyChangesFromSyncModel may be too slow to be 46 // The changes found in ApplyChangesFromSyncModel may be too slow to be
47 // performed while holding a [Read/Write]Transaction lock or may interact 47 // performed while holding a [Read/Write]Transaction lock or may interact
48 // with another thread, which might itself be waiting on the transaction lock, 48 // with another thread, which might itself be waiting on the transaction lock,
49 // putting us at risk of deadlock. 49 // putting us at risk of deadlock.
50 // This function is called once the transactional lock is released and it is 50 // This function is called once the transactional lock is released and it is
51 // safe to perform inter-thread or slow I/O operations. Note that not all 51 // safe to perform inter-thread or slow I/O operations. Note that not all
52 // datatypes need this, so we provide an empty default version. 52 // datatypes need this, so we provide an empty default version.
53 virtual void CommitChangesFromSyncModel(); 53 virtual void CommitChangesFromSyncModel();
54 54
55 // This ensures that startobserving gets called after stopobserving even
56 // if there is an early return in the function.
57 template <class T>
58 class ScopedStopObserving {
59 public:
60 explicit ScopedStopObserving(T* processor)
61 : processor_(processor) {
62 processor_->StopObserving();
63 }
64 ~ScopedStopObserving() {
65 processor_->StartObserving();
66 }
67
68 private:
69 ScopedStopObserving() {}
70 T* processor_;
71 };
72
55 protected: 73 protected:
56 // These methods are invoked by Start() and Stop() to do 74 // These methods are invoked by Start() and Stop() to do
57 // implementation-specific work. 75 // implementation-specific work.
58 virtual void StartImpl(Profile* profile) = 0; 76 virtual void StartImpl(Profile* profile) = 0;
59 virtual void StopImpl() = 0; 77 virtual void StopImpl() = 0;
60 78
61 bool running() { return running_; } 79 bool running() { return running_; }
62 UnrecoverableErrorHandler* error_handler(); 80 UnrecoverableErrorHandler* error_handler();
63 virtual sync_api::UserShare* share_handle(); 81 virtual sync_api::UserShare* share_handle();
64 82
65 private: 83 private:
66 bool running_; // True if we have been told it is safe to process changes. 84 bool running_; // True if we have been told it is safe to process changes.
67 UnrecoverableErrorHandler* error_handler_; // Guaranteed to outlive us. 85 UnrecoverableErrorHandler* error_handler_; // Guaranteed to outlive us.
68 86
69 // The sync model we are processing changes from. Non-NULL when |running_| is 87 // The sync model we are processing changes from. Non-NULL when |running_| is
70 // true. 88 // true.
71 sync_api::UserShare* share_handle_; 89 sync_api::UserShare* share_handle_;
72 90
73 DISALLOW_COPY_AND_ASSIGN(ChangeProcessor); 91 DISALLOW_COPY_AND_ASSIGN(ChangeProcessor);
74 }; 92 };
75 93
76 } // namespace browser_sync 94 } // namespace browser_sync
77 95
78 #endif // CHROME_BROWSER_SYNC_GLUE_CHANGE_PROCESSOR_H_ 96 #endif // CHROME_BROWSER_SYNC_GLUE_CHANGE_PROCESSOR_H_
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/autofill_profile_change_processor.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698