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

Side by Side Diff: components/sync/driver/generic_change_processor.cc

Issue 2769113002: [Sync] Stop accessing BrowserContextKeyedServiceFactory on non-UI thread. (Closed)
Patch Set: Rebase and removing dependent patch set. Created 3 years, 8 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/sync/driver/generic_change_processor.h" 5 #include "components/sync/driver/generic_change_processor.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/location.h" 12 #include "base/location.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
16 #include "base/threading/sequenced_task_runner_handle.h" 16 #include "base/threading/sequenced_task_runner_handle.h"
17 #include "components/sync/base/unrecoverable_error_handler.h" 17 #include "components/sync/base/unrecoverable_error_handler.h"
18 #include "components/sync/driver/sync_api_component_factory.h" 18 #include "components/sync/driver/sync_api_component_factory.h"
19 #include "components/sync/driver/sync_client.h"
20 #include "components/sync/model/local_change_observer.h" 19 #include "components/sync/model/local_change_observer.h"
21 #include "components/sync/model/sync_change.h" 20 #include "components/sync/model/sync_change.h"
22 #include "components/sync/model/sync_error.h" 21 #include "components/sync/model/sync_error.h"
23 #include "components/sync/model/syncable_service.h" 22 #include "components/sync/model/syncable_service.h"
24 #include "components/sync/syncable/base_node.h" 23 #include "components/sync/syncable/base_node.h"
25 #include "components/sync/syncable/change_record.h" 24 #include "components/sync/syncable/change_record.h"
26 #include "components/sync/syncable/entry.h" // TODO(tim): Bug 123674. 25 #include "components/sync/syncable/entry.h" // TODO(tim): Bug 123674.
27 #include "components/sync/syncable/read_node.h" 26 #include "components/sync/syncable/read_node.h"
28 #include "components/sync/syncable/read_transaction.h" 27 #include "components/sync/syncable/read_transaction.h"
29 #include "components/sync/syncable/write_node.h" 28 #include "components/sync/syncable/write_node.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 } 103 }
105 104
106 } // namespace 105 } // namespace
107 106
108 GenericChangeProcessor::GenericChangeProcessor( 107 GenericChangeProcessor::GenericChangeProcessor(
109 ModelType type, 108 ModelType type,
110 std::unique_ptr<DataTypeErrorHandler> error_handler, 109 std::unique_ptr<DataTypeErrorHandler> error_handler,
111 const base::WeakPtr<SyncableService>& local_service, 110 const base::WeakPtr<SyncableService>& local_service,
112 const base::WeakPtr<SyncMergeResult>& merge_result, 111 const base::WeakPtr<SyncMergeResult>& merge_result,
113 UserShare* user_share, 112 UserShare* user_share,
114 SyncClient* sync_client, 113 SyncApiComponentFactory* driver_factory,
115 std::unique_ptr<AttachmentStoreForSync> attachment_store) 114 std::unique_ptr<AttachmentStoreForSync> attachment_store)
116 : ChangeProcessor(std::move(error_handler)), 115 : ChangeProcessor(std::move(error_handler)),
117 type_(type), 116 type_(type),
118 local_service_(local_service), 117 local_service_(local_service),
119 merge_result_(merge_result), 118 merge_result_(merge_result),
120 share_handle_(user_share), 119 share_handle_(user_share),
121 weak_ptr_factory_(this) { 120 weak_ptr_factory_(this) {
122 DCHECK(sequence_checker_.CalledOnValidSequence()); 121 DCHECK(sequence_checker_.CalledOnValidSequence());
123 DCHECK_NE(type_, UNSPECIFIED); 122 DCHECK_NE(type_, UNSPECIFIED);
124 if (attachment_store) { 123 if (attachment_store) {
125 std::string store_birthday; 124 std::string store_birthday;
126 { 125 {
127 ReadTransaction trans(FROM_HERE, share_handle()); 126 ReadTransaction trans(FROM_HERE, share_handle());
128 store_birthday = trans.GetStoreBirthday(); 127 store_birthday = trans.GetStoreBirthday();
129 } 128 }
130 attachment_service_ = 129 attachment_service_ = driver_factory->CreateAttachmentService(
131 sync_client->GetSyncApiComponentFactory()->CreateAttachmentService( 130 std::move(attachment_store), *user_share, store_birthday, type, this);
132 std::move(attachment_store), *user_share, store_birthday, type,
133 this);
134 attachment_service_weak_ptr_factory_ = 131 attachment_service_weak_ptr_factory_ =
135 base::MakeUnique<base::WeakPtrFactory<AttachmentService>>( 132 base::MakeUnique<base::WeakPtrFactory<AttachmentService>>(
136 attachment_service_.get()); 133 attachment_service_.get());
137 attachment_service_proxy_ = AttachmentServiceProxy( 134 attachment_service_proxy_ = AttachmentServiceProxy(
138 base::SequencedTaskRunnerHandle::Get(), 135 base::SequencedTaskRunnerHandle::Get(),
139 attachment_service_weak_ptr_factory_->GetWeakPtr()); 136 attachment_service_weak_ptr_factory_->GetWeakPtr());
140 UploadAllAttachmentsNotOnServer(); 137 UploadAllAttachmentsNotOnServer();
141 } else { 138 } else {
142 attachment_service_proxy_ = 139 attachment_service_proxy_ =
143 AttachmentServiceProxy(base::SequencedTaskRunnerHandle::Get(), 140 AttachmentServiceProxy(base::SequencedTaskRunnerHandle::Get(),
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 observer.OnLocalChange(current_entry, change); 696 observer.OnLocalChange(current_entry, change);
700 } 697 }
701 698
702 std::unique_ptr<AttachmentService> 699 std::unique_ptr<AttachmentService>
703 GenericChangeProcessor::GetAttachmentService() const { 700 GenericChangeProcessor::GetAttachmentService() const {
704 return std::unique_ptr<AttachmentService>( 701 return std::unique_ptr<AttachmentService>(
705 new AttachmentServiceProxy(attachment_service_proxy_)); 702 new AttachmentServiceProxy(attachment_service_proxy_));
706 } 703 }
707 704
708 } // namespace syncer 705 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/driver/generic_change_processor.h ('k') | components/sync/driver/generic_change_processor_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698