Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #import "ios/web/browsing_data_partition_impl.h" | 5 #import "ios/web/browsing_data_partition_impl.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "ios/web/public/browser_state.h" | 8 #include "ios/web/public/browser_state.h" |
| 9 #include "ios/web/public/browsing_data_partition_client.h" | |
| 9 #import "ios/web/public/crw_browsing_data_store.h" | 10 #import "ios/web/public/crw_browsing_data_store.h" |
| 10 #include "ios/web/public/web_thread.h" | 11 #include "ios/web/public/web_thread.h" |
| 11 | 12 |
| 12 // A class that observes the |mode| changes in a CRWBrowsingDataStore using KVO. | 13 // A class that observes the |mode| changes in a CRWBrowsingDataStore using KVO. |
| 13 // Maintains a count of all the CRWBrowsingDataStores whose mode is out of sync | 14 // Maintains a count of all the CRWBrowsingDataStores whose mode is out of sync |
| 14 // with their corresponding ActiveStateManager's active state. | 15 // with their corresponding ActiveStateManager's active state. |
| 15 @interface CRWBrowsingDataStoreModeObserver : NSObject | 16 @interface CRWBrowsingDataStoreModeObserver : NSObject |
| 16 | 17 |
| 17 // The total count of the CRWBrowsingDataStores -- that are being observed -- | 18 // The total count of the CRWBrowsingDataStores -- that are being observed -- |
| 18 // whose mode is out of sync with their associated ActiveStateManager's active | 19 // whose mode is out of sync with their associated ActiveStateManager's active |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 77 // Check if the |browsingDataStore|'s associated ActiveStateManager's active | 78 // Check if the |browsingDataStore|'s associated ActiveStateManager's active |
| 78 // state is still out of sync. | 79 // state is still out of sync. |
| 79 if (activeState && browsingDataStore.mode == web::INACTIVE) { | 80 if (activeState && browsingDataStore.mode == web::INACTIVE) { |
| 80 [browsingDataStore makeActiveWithCompletionHandler:nil]; | 81 [browsingDataStore makeActiveWithCompletionHandler:nil]; |
| 81 } else if (!activeState && browsingDataStore.mode == web::ACTIVE) { | 82 } else if (!activeState && browsingDataStore.mode == web::ACTIVE) { |
| 82 [browsingDataStore makeInactiveWithCompletionHandler:nil]; | 83 [browsingDataStore makeInactiveWithCompletionHandler:nil]; |
| 83 } | 84 } |
| 84 | 85 |
| 85 DCHECK_GE(self.outOfSyncStoreCount, 1U); | 86 DCHECK_GE(self.outOfSyncStoreCount, 1U); |
| 86 --self.outOfSyncStoreCount; | 87 --self.outOfSyncStoreCount; |
| 87 // TODO(shreyasv): Have a BrowsingDataPartitionClient be informed when | 88 web::BrowsingDataPartitionClient* client = |
|
Eugene But (OOO till 7-30)
2015/07/21 21:48:03
NIT: Please either use auto or inline web::GetBrow
shreyasv1
2015/07/21 22:12:06
Acknowledged.
| |
| 88 // |self.outOfSyncStoreCount| goes down to 0. crbug.com/480654. | 89 web::GetBrowsingDataPartitionClient(); |
| 90 if (client) { | |
| 91 client->DidBecomeSynchronized(); | |
| 92 } | |
| 89 } | 93 } |
| 90 | 94 |
| 91 @end | 95 @end |
| 92 | 96 |
| 93 namespace web { | 97 namespace web { |
| 94 | 98 |
| 95 namespace { | 99 namespace { |
| 96 // The global observer that tracks the number of CRWBrowsingDataStores whose | 100 // The global observer that tracks the number of CRWBrowsingDataStores whose |
| 97 // modes are out of sync with their associated ActiveStateManager's active | 101 // modes are out of sync with their associated ActiveStateManager's active |
| 98 // state. | 102 // state. |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 155 } | 159 } |
| 156 | 160 |
| 157 void BrowsingDataPartitionImpl::WillBeDestroyed() { | 161 void BrowsingDataPartitionImpl::WillBeDestroyed() { |
| 158 DCHECK_CURRENTLY_ON_WEB_THREAD(WebThread::UI); | 162 DCHECK_CURRENTLY_ON_WEB_THREAD(WebThread::UI); |
| 159 | 163 |
| 160 active_state_manager_->RemoveObserver(this); | 164 active_state_manager_->RemoveObserver(this); |
| 161 active_state_manager_ = nullptr; | 165 active_state_manager_ = nullptr; |
| 162 } | 166 } |
| 163 | 167 |
| 164 } // namespace web | 168 } // namespace web |
| OLD | NEW |