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

Side by Side Diff: components/history/core/browser/history_delete_directives_data_type_controller.cc

Issue 2657673004: Add shutdown notification and service refs to SyncServiceObserver. (Closed)
Patch Set: Chromeos fix Created 3 years, 10 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/history/core/browser/history_delete_directives_data_type_co ntroller.h" 5 #include "components/history/core/browser/history_delete_directives_data_type_co ntroller.h"
6 6
7 #include "base/threading/thread_task_runner_handle.h" 7 #include "base/threading/thread_task_runner_handle.h"
8 #include "components/sync/driver/sync_client.h" 8 #include "components/sync/driver/sync_client.h"
9 #include "components/sync/driver/sync_service.h" 9 #include "components/sync/driver/sync_service.h"
10 10
(...skipping 25 matching lines...) Expand all
36 sync_client_->GetSyncService()->AddObserver(this); 36 sync_client_->GetSyncService()->AddObserver(this);
37 return true; 37 return true;
38 } 38 }
39 39
40 void HistoryDeleteDirectivesDataTypeController::StopModels() { 40 void HistoryDeleteDirectivesDataTypeController::StopModels() {
41 DCHECK(CalledOnValidThread()); 41 DCHECK(CalledOnValidThread());
42 if (sync_client_->GetSyncService()->HasObserver(this)) 42 if (sync_client_->GetSyncService()->HasObserver(this))
43 sync_client_->GetSyncService()->RemoveObserver(this); 43 sync_client_->GetSyncService()->RemoveObserver(this);
44 } 44 }
45 45
46 void HistoryDeleteDirectivesDataTypeController::OnStateChanged() { 46 void HistoryDeleteDirectivesDataTypeController::OnStateChanged(
47 syncer::SyncService* sync) {
47 DisableTypeIfNecessary(); 48 DisableTypeIfNecessary();
48 } 49 }
49 50
50 bool HistoryDeleteDirectivesDataTypeController::DisableTypeIfNecessary() { 51 bool HistoryDeleteDirectivesDataTypeController::DisableTypeIfNecessary() {
51 DCHECK(CalledOnValidThread()); 52 DCHECK(CalledOnValidThread());
52 if (!sync_client_->GetSyncService()->IsSyncActive()) 53 if (!sync_client_->GetSyncService()->IsSyncActive())
53 return false; 54 return false;
54 55
55 if (ReadyForStart()) 56 if (ReadyForStart())
56 return false; 57 return false;
57 58
58 if (sync_client_->GetSyncService()->HasObserver(this)) 59 if (sync_client_->GetSyncService()->HasObserver(this))
59 sync_client_->GetSyncService()->RemoveObserver(this); 60 sync_client_->GetSyncService()->RemoveObserver(this);
60 syncer::SyncError error( 61 syncer::SyncError error(
61 FROM_HERE, 62 FROM_HERE,
62 syncer::SyncError::DATATYPE_POLICY_ERROR, 63 syncer::SyncError::DATATYPE_POLICY_ERROR,
63 "Delete directives not supported with encryption.", 64 "Delete directives not supported with encryption.",
64 type()); 65 type());
65 CreateErrorHandler()->OnUnrecoverableError(error); 66 CreateErrorHandler()->OnUnrecoverableError(error);
66 return true; 67 return true;
67 } 68 }
68 69
69 } // namespace browser_sync 70 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698