OLD | NEW |
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 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 | 292 |
293 void DeleteDirectiveHandler::Start( | 293 void DeleteDirectiveHandler::Start( |
294 HistoryService* history_service, | 294 HistoryService* history_service, |
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 scoped_ptr<history::HistoryDBTask>( | 302 new DeleteDirectiveTask(weak_ptr_factory_.GetWeakPtr(), |
303 new DeleteDirectiveTask(weak_ptr_factory_.GetWeakPtr(), | 303 initial_sync_data, |
304 initial_sync_data, | 304 DROP_AFTER_PROCESSING), |
305 DROP_AFTER_PROCESSING)), | |
306 &internal_tracker_); | 305 &internal_tracker_); |
307 } | 306 } |
308 } | 307 } |
309 | 308 |
310 void DeleteDirectiveHandler::Stop() { | 309 void DeleteDirectiveHandler::Stop() { |
311 DCHECK(thread_checker_.CalledOnValidThread()); | 310 DCHECK(thread_checker_.CalledOnValidThread()); |
312 sync_processor_.reset(); | 311 sync_processor_.reset(); |
313 } | 312 } |
314 | 313 |
315 bool DeleteDirectiveHandler::CreateDeleteDirectives( | 314 bool DeleteDirectiveHandler::CreateDeleteDirectives( |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 NOTREACHED(); | 402 NOTREACHED(); |
404 break; | 403 break; |
405 } | 404 } |
406 } | 405 } |
407 | 406 |
408 if (!delete_directives.empty()) { | 407 if (!delete_directives.empty()) { |
409 // 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 |
410 // redelivered delete directives to avoid processing them again and again | 409 // redelivered delete directives to avoid processing them again and again |
411 // in one chrome session. | 410 // in one chrome session. |
412 history_service->ScheduleDBTask( | 411 history_service->ScheduleDBTask( |
413 scoped_ptr<history::HistoryDBTask>( | 412 new DeleteDirectiveTask(weak_ptr_factory_.GetWeakPtr(), |
414 new DeleteDirectiveTask(weak_ptr_factory_.GetWeakPtr(), | 413 delete_directives, |
415 delete_directives, | 414 KEEP_AFTER_PROCESSING), |
416 KEEP_AFTER_PROCESSING)), | |
417 &internal_tracker_); | 415 &internal_tracker_); |
418 } | 416 } |
419 return syncer::SyncError(); | 417 return syncer::SyncError(); |
420 } | 418 } |
421 | 419 |
422 void DeleteDirectiveHandler::FinishProcessing( | 420 void DeleteDirectiveHandler::FinishProcessing( |
423 PostProcessingAction post_processing_action, | 421 PostProcessingAction post_processing_action, |
424 const syncer::SyncDataList& delete_directives) { | 422 const syncer::SyncDataList& delete_directives) { |
425 DCHECK(thread_checker_.CalledOnValidThread()); | 423 DCHECK(thread_checker_.CalledOnValidThread()); |
426 | 424 |
427 // If specified, drop processed delete directive in sync model because they | 425 // If specified, drop processed delete directive in sync model because they |
428 // only need to be applied once. | 426 // only need to be applied once. |
429 if (sync_processor_.get() && | 427 if (sync_processor_.get() && |
430 post_processing_action == DROP_AFTER_PROCESSING) { | 428 post_processing_action == DROP_AFTER_PROCESSING) { |
431 syncer::SyncChangeList change_list; | 429 syncer::SyncChangeList change_list; |
432 for (size_t i = 0; i < delete_directives.size(); ++i) { | 430 for (size_t i = 0; i < delete_directives.size(); ++i) { |
433 change_list.push_back( | 431 change_list.push_back( |
434 syncer::SyncChange(FROM_HERE, syncer::SyncChange::ACTION_DELETE, | 432 syncer::SyncChange(FROM_HERE, syncer::SyncChange::ACTION_DELETE, |
435 delete_directives[i])); | 433 delete_directives[i])); |
436 } | 434 } |
437 sync_processor_->ProcessSyncChanges(FROM_HERE, change_list); | 435 sync_processor_->ProcessSyncChanges(FROM_HERE, change_list); |
438 } | 436 } |
439 } | 437 } |
440 | 438 |
441 } // namespace history | 439 } // namespace history |
OLD | NEW |