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

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

Issue 9307079: [Sync] Fix thread-ordering-dependent NULL dereference in NewNonFrontendDTC (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync to head Created 8 years, 10 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_SHARED_CHANGE_PROCESSOR_H_ 5 #ifndef CHROME_BROWSER_SYNC_GLUE_SHARED_CHANGE_PROCESSOR_H_
6 #define CHROME_BROWSER_SYNC_GLUE_SHARED_CHANGE_PROCESSOR_H_ 6 #define CHROME_BROWSER_SYNC_GLUE_SHARED_CHANGE_PROCESSOR_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/message_loop_proxy.h"
13 #include "base/synchronization/lock.h" 13 #include "base/synchronization/lock.h"
14 #include "base/threading/thread_checker.h"
15 #include "chrome/browser/sync/api/sync_change_processor.h" 14 #include "chrome/browser/sync/api/sync_change_processor.h"
16 #include "chrome/browser/sync/api/sync_error.h" 15 #include "chrome/browser/sync/api/sync_error.h"
17 #include "chrome/browser/sync/engine/model_safe_worker.h" 16 #include "chrome/browser/sync/engine/model_safe_worker.h"
18 17
19 class ProfileSyncComponentsFactory; 18 class ProfileSyncComponentsFactory;
20 class ProfileSyncService; 19 class ProfileSyncService;
21 class SyncData; 20 class SyncData;
22 class SyncableService; 21 class SyncableService;
23 22
24 typedef std::vector<SyncData> SyncDataList; 23 typedef std::vector<SyncData> SyncDataList;
(...skipping 14 matching lines...) Expand all
39 // The only thread-safe method is Disconnect, which will disconnect from the 38 // The only thread-safe method is Disconnect, which will disconnect from the
40 // generic change processor, letting us shut down the syncer/datatype without 39 // generic change processor, letting us shut down the syncer/datatype without
41 // waiting for non-UI threads. 40 // waiting for non-UI threads.
42 // 41 //
43 // Note: since we control the work being done while holding the lock, we ensure 42 // Note: since we control the work being done while holding the lock, we ensure
44 // no I/O or other intensive work is done while blocking the UI thread (all 43 // no I/O or other intensive work is done while blocking the UI thread (all
45 // the work is in-memory sync interactions). 44 // the work is in-memory sync interactions).
46 // 45 //
47 // We use virtual methods so that we can use mock's in testing. 46 // We use virtual methods so that we can use mock's in testing.
48 class SharedChangeProcessor 47 class SharedChangeProcessor
49 : public base::RefCountedThreadSafe<SharedChangeProcessor>, 48 : public base::RefCountedThreadSafe<SharedChangeProcessor> {
50 public base::ThreadChecker {
51 public: 49 public:
52 // Create an uninitialized SharedChangeProcessor (to be later connected). 50 // Create an uninitialized SharedChangeProcessor (to be later connected).
53 SharedChangeProcessor(); 51 SharedChangeProcessor();
54 52
55 // Connect to the Syncer. Will create and hold a new GenericChangeProcessor. 53 // Connect to the Syncer. Will create and hold a new GenericChangeProcessor.
56 // Returns: true if successful, false if disconnected or |local_service| was 54 // Returns: true if successful, false if disconnected or |local_service| was
57 // NULL. 55 // NULL.
58 virtual bool Connect( 56 virtual bool Connect(
59 ProfileSyncComponentsFactory* sync_factory, 57 ProfileSyncComponentsFactory* sync_factory,
60 ProfileSyncService* sync_service, 58 ProfileSyncService* sync_service,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 94
97 private: 95 private:
98 // Monitor lock for this object. All methods that interact with the change 96 // Monitor lock for this object. All methods that interact with the change
99 // processor must aquire this lock and check whether we're disconnected or 97 // processor must aquire this lock and check whether we're disconnected or
100 // not. Once disconnected, all attempted changes to or loads from the change 98 // not. Once disconnected, all attempted changes to or loads from the change
101 // processor return errors. This enables us to shut down the syncer without 99 // processor return errors. This enables us to shut down the syncer without
102 // having to wait for possibly non-UI thread datatypes to complete work. 100 // having to wait for possibly non-UI thread datatypes to complete work.
103 mutable base::Lock monitor_lock_; 101 mutable base::Lock monitor_lock_;
104 bool disconnected_; 102 bool disconnected_;
105 103
106 scoped_ptr<GenericChangeProcessor> generic_change_processor_; 104 // The loop that all methods except the constructor, destructor, and
105 // Disconnect() should be called on. Set in Connect().
106 scoped_refptr<base::MessageLoopProxy> backend_loop_;
107
108 // Used only on |backend_loop_|.
109 GenericChangeProcessor* generic_change_processor_;
107 110
108 DISALLOW_COPY_AND_ASSIGN(SharedChangeProcessor); 111 DISALLOW_COPY_AND_ASSIGN(SharedChangeProcessor);
109 }; 112 };
110 113
111 } // namespace browser_sync 114 } // namespace browser_sync
112 115
113 #endif // CHROME_BROWSER_SYNC_GLUE_SHARED_CHANGE_PROCESSOR_H_ 116 #endif // CHROME_BROWSER_SYNC_GLUE_SHARED_CHANGE_PROCESSOR_H_
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/non_frontend_data_type_controller.h ('k') | chrome/browser/sync/glue/shared_change_processor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698