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

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

Issue 387923002: Make HistoryDBTask not refcounted, and ensure it's destroyed on its origin thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: revert unnecessary changes 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
« no previous file with comments | « no previous file | chrome/browser/history/history_backend.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 new DeleteDirectiveTask(weak_ptr_factory_.GetWeakPtr(), 302 scoped_ptr<history::HistoryDBTask>(
303 initial_sync_data, 303 new DeleteDirectiveTask(weak_ptr_factory_.GetWeakPtr(),
304 DROP_AFTER_PROCESSING), 304 initial_sync_data,
305 DROP_AFTER_PROCESSING)),
305 &internal_tracker_); 306 &internal_tracker_);
306 } 307 }
307 } 308 }
308 309
309 void DeleteDirectiveHandler::Stop() { 310 void DeleteDirectiveHandler::Stop() {
310 DCHECK(thread_checker_.CalledOnValidThread()); 311 DCHECK(thread_checker_.CalledOnValidThread());
311 sync_processor_.reset(); 312 sync_processor_.reset();
312 } 313 }
313 314
314 bool DeleteDirectiveHandler::CreateDeleteDirectives( 315 bool DeleteDirectiveHandler::CreateDeleteDirectives(
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 NOTREACHED(); 403 NOTREACHED();
403 break; 404 break;
404 } 405 }
405 } 406 }
406 407
407 if (!delete_directives.empty()) { 408 if (!delete_directives.empty()) {
408 // Don't drop real-time delete directive so that sync engine can detect 409 // Don't drop real-time delete directive so that sync engine can detect
409 // redelivered delete directives to avoid processing them again and again 410 // redelivered delete directives to avoid processing them again and again
410 // in one chrome session. 411 // in one chrome session.
411 history_service->ScheduleDBTask( 412 history_service->ScheduleDBTask(
412 new DeleteDirectiveTask(weak_ptr_factory_.GetWeakPtr(), 413 scoped_ptr<history::HistoryDBTask>(
413 delete_directives, 414 new DeleteDirectiveTask(weak_ptr_factory_.GetWeakPtr(),
414 KEEP_AFTER_PROCESSING), 415 delete_directives,
416 KEEP_AFTER_PROCESSING)),
415 &internal_tracker_); 417 &internal_tracker_);
416 } 418 }
417 return syncer::SyncError(); 419 return syncer::SyncError();
418 } 420 }
419 421
420 void DeleteDirectiveHandler::FinishProcessing( 422 void DeleteDirectiveHandler::FinishProcessing(
421 PostProcessingAction post_processing_action, 423 PostProcessingAction post_processing_action,
422 const syncer::SyncDataList& delete_directives) { 424 const syncer::SyncDataList& delete_directives) {
423 DCHECK(thread_checker_.CalledOnValidThread()); 425 DCHECK(thread_checker_.CalledOnValidThread());
424 426
425 // If specified, drop processed delete directive in sync model because they 427 // If specified, drop processed delete directive in sync model because they
426 // only need to be applied once. 428 // only need to be applied once.
427 if (sync_processor_.get() && 429 if (sync_processor_.get() &&
428 post_processing_action == DROP_AFTER_PROCESSING) { 430 post_processing_action == DROP_AFTER_PROCESSING) {
429 syncer::SyncChangeList change_list; 431 syncer::SyncChangeList change_list;
430 for (size_t i = 0; i < delete_directives.size(); ++i) { 432 for (size_t i = 0; i < delete_directives.size(); ++i) {
431 change_list.push_back( 433 change_list.push_back(
432 syncer::SyncChange(FROM_HERE, syncer::SyncChange::ACTION_DELETE, 434 syncer::SyncChange(FROM_HERE, syncer::SyncChange::ACTION_DELETE,
433 delete_directives[i])); 435 delete_directives[i]));
434 } 436 }
435 sync_processor_->ProcessSyncChanges(FROM_HERE, change_list); 437 sync_processor_->ProcessSyncChanges(FROM_HERE, change_list);
436 } 438 }
437 } 439 }
438 440
439 } // namespace history 441 } // namespace history
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/history/history_backend.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698