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

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

Issue 272043002: Invoke AttachmentUploader and update AttachmentIds. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Android build Created 6 years, 7 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 (c) 2012 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 #include "chrome/browser/sync/glue/shared_change_processor.h" 5 #include "chrome/browser/sync/glue/shared_change_processor.h"
6 6
7 #include "base/message_loop/message_loop_proxy.h" 7 #include "base/message_loop/message_loop_proxy.h"
8 #include "components/sync_driver/generic_change_processor.h" 8 #include "components/sync_driver/generic_change_processor.h"
9 #include "components/sync_driver/generic_change_processor_factory.h" 9 #include "components/sync_driver/generic_change_processor_factory.h"
10 #include "components/sync_driver/sync_api_component_factory.h" 10 #include "components/sync_driver/sync_api_component_factory.h"
11 #include "sync/api/attachments/attachment_service.h"
12 #include "sync/api/attachments/attachment_service_impl.h"
13 #include "sync/api/sync_change.h" 11 #include "sync/api/sync_change.h"
14 #include "sync/internal_api/public/attachments/fake_attachment_uploader.h"
15 12
16 using base::AutoLock; 13 using base::AutoLock;
17 14
18 namespace browser_sync { 15 namespace browser_sync {
19 16
20 SharedChangeProcessor::SharedChangeProcessor() 17 SharedChangeProcessor::SharedChangeProcessor()
21 : disconnected_(false), 18 : disconnected_(false),
22 type_(syncer::UNSPECIFIED), 19 type_(syncer::UNSPECIFIED),
23 frontend_loop_(base::MessageLoopProxy::current()), 20 frontend_loop_(base::MessageLoopProxy::current()),
24 generic_change_processor_(NULL), 21 generic_change_processor_(NULL),
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 type_ = type; 59 type_ = type;
63 error_handler_ = error_handler; 60 error_handler_ = error_handler;
64 base::WeakPtr<syncer::SyncableService> local_service = 61 base::WeakPtr<syncer::SyncableService> local_service =
65 sync_factory->GetSyncableServiceForType(type); 62 sync_factory->GetSyncableServiceForType(type);
66 if (!local_service.get()) { 63 if (!local_service.get()) {
67 LOG(WARNING) << "SyncableService destroyed before DTC was stopped."; 64 LOG(WARNING) << "SyncableService destroyed before DTC was stopped.";
68 disconnected_ = true; 65 disconnected_ = true;
69 return base::WeakPtr<syncer::SyncableService>(); 66 return base::WeakPtr<syncer::SyncableService>();
70 } 67 }
71 68
72 // TODO(maniscalco): Use a shared (one per profile) thread-safe instance of 69 generic_change_processor_ =
73 // AttachmentUpload instead of creating a new one per AttachmentService (bug 70 processor_factory->CreateGenericChangeProcessor(user_share,
74 // 369536). 71 error_handler,
75 scoped_ptr<syncer::AttachmentUploader> attachment_uploader( 72 local_service,
76 new syncer::FakeAttachmentUploader); 73 merge_result,
77 74 sync_factory).release();
78 scoped_ptr<syncer::AttachmentService> attachment_service(
79 new syncer::AttachmentServiceImpl(
80 sync_factory->CreateCustomAttachmentStoreForType(type),
81 attachment_uploader.Pass()));
82
83 generic_change_processor_ = processor_factory->CreateGenericChangeProcessor(
84 user_share,
85 error_handler,
86 local_service,
87 merge_result,
88 attachment_service.Pass()).release();
89 return local_service; 75 return local_service;
90 } 76 }
91 77
92 bool SharedChangeProcessor::Disconnect() { 78 bool SharedChangeProcessor::Disconnect() {
93 // May be called from any thread. 79 // May be called from any thread.
94 DVLOG(1) << "Disconnecting change processor."; 80 DVLOG(1) << "Disconnecting change processor.";
95 AutoLock lock(monitor_lock_); 81 AutoLock lock(monitor_lock_);
96 bool was_connected = !disconnected_; 82 bool was_connected = !disconnected_;
97 disconnected_ = true; 83 disconnected_ = true;
98 error_handler_ = NULL; 84 error_handler_ = NULL;
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 return error_handler_->CreateAndUploadError(location, message, type_); 202 return error_handler_->CreateAndUploadError(location, message, type_);
217 } else { 203 } else {
218 return syncer::SyncError(location, 204 return syncer::SyncError(location,
219 syncer::SyncError::DATATYPE_ERROR, 205 syncer::SyncError::DATATYPE_ERROR,
220 message, 206 message,
221 type_); 207 type_);
222 } 208 }
223 } 209 }
224 210
225 } // namespace browser_sync 211 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698