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

Side by Side Diff: chrome/browser/history/delete_directive_handler.cc

Issue 352913002: Port HistoryService::ScheduleDBTask to CancelableTaskTracker (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/history/delete_directive_handler.h" 5 #include "chrome/browser/history/delete_directive_handler.h"
6 6
7 #include "base/json/json_writer.h" 7 #include "base/json/json_writer.h"
8 #include "base/rand_util.h" 8 #include "base/rand_util.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 const syncer::SyncDataList& initial_sync_data, 295 const syncer::SyncDataList& initial_sync_data,
296 scoped_ptr<syncer::SyncChangeProcessor> sync_processor) { 296 scoped_ptr<syncer::SyncChangeProcessor> sync_processor) {
297 DCHECK(thread_checker_.CalledOnValidThread()); 297 DCHECK(thread_checker_.CalledOnValidThread());
298 sync_processor_ = sync_processor.Pass(); 298 sync_processor_ = sync_processor.Pass();
299 if (!initial_sync_data.empty()) { 299 if (!initial_sync_data.empty()) {
300 // Drop processed delete directives during startup. 300 // Drop processed delete directives during startup.
301 history_service->ScheduleDBTask( 301 history_service->ScheduleDBTask(
302 new DeleteDirectiveTask(weak_ptr_factory_.GetWeakPtr(), 302 new DeleteDirectiveTask(weak_ptr_factory_.GetWeakPtr(),
303 initial_sync_data, 303 initial_sync_data,
304 DROP_AFTER_PROCESSING), 304 DROP_AFTER_PROCESSING),
305 &internal_consumer_); 305 &internal_tracker_);
306 } 306 }
307 } 307 }
308 308
309 void DeleteDirectiveHandler::Stop() { 309 void DeleteDirectiveHandler::Stop() {
310 DCHECK(thread_checker_.CalledOnValidThread()); 310 DCHECK(thread_checker_.CalledOnValidThread());
311 sync_processor_.reset(); 311 sync_processor_.reset();
312 } 312 }
313 313
314 bool DeleteDirectiveHandler::CreateDeleteDirectives( 314 bool DeleteDirectiveHandler::CreateDeleteDirectives(
315 const std::set<int64>& global_ids, 315 const std::set<int64>& global_ids,
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 } 404 }
405 } 405 }
406 406
407 if (!delete_directives.empty()) { 407 if (!delete_directives.empty()) {
408 // Don't drop real-time delete directive so that sync engine can detect 408 // Don't drop real-time delete directive so that sync engine can detect
409 // redelivered delete directives to avoid processing them again and again 409 // redelivered delete directives to avoid processing them again and again
410 // in one chrome session. 410 // in one chrome session.
411 history_service->ScheduleDBTask( 411 history_service->ScheduleDBTask(
412 new DeleteDirectiveTask(weak_ptr_factory_.GetWeakPtr(), 412 new DeleteDirectiveTask(weak_ptr_factory_.GetWeakPtr(),
413 delete_directives, KEEP_AFTER_PROCESSING), 413 delete_directives, KEEP_AFTER_PROCESSING),
414 &internal_consumer_); 414 &internal_tracker_);
415 } 415 }
416 return syncer::SyncError(); 416 return syncer::SyncError();
417 } 417 }
418 418
419 void DeleteDirectiveHandler::FinishProcessing( 419 void DeleteDirectiveHandler::FinishProcessing(
420 PostProcessingAction post_processing_action, 420 PostProcessingAction post_processing_action,
421 const syncer::SyncDataList& delete_directives) { 421 const syncer::SyncDataList& delete_directives) {
422 DCHECK(thread_checker_.CalledOnValidThread()); 422 DCHECK(thread_checker_.CalledOnValidThread());
423 423
424 // If specified, drop processed delete directive in sync model because they 424 // If specified, drop processed delete directive in sync model because they
425 // only need to be applied once. 425 // only need to be applied once.
426 if (sync_processor_.get() && 426 if (sync_processor_.get() &&
427 post_processing_action == DROP_AFTER_PROCESSING) { 427 post_processing_action == DROP_AFTER_PROCESSING) {
428 syncer::SyncChangeList change_list; 428 syncer::SyncChangeList change_list;
429 for (size_t i = 0; i < delete_directives.size(); ++i) { 429 for (size_t i = 0; i < delete_directives.size(); ++i) {
430 change_list.push_back( 430 change_list.push_back(
431 syncer::SyncChange(FROM_HERE, syncer::SyncChange::ACTION_DELETE, 431 syncer::SyncChange(FROM_HERE, syncer::SyncChange::ACTION_DELETE,
432 delete_directives[i])); 432 delete_directives[i]));
433 } 433 }
434 sync_processor_->ProcessSyncChanges(FROM_HERE, change_list); 434 sync_processor_->ProcessSyncChanges(FROM_HERE, change_list);
435 } 435 }
436 } 436 }
437 437
438 } // namespace history 438 } // namespace history
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698