| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_ | 5 #ifndef CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_ |
| 6 #define CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_ | 6 #define CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <queue> | 10 #include <queue> |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 // | 87 // |
| 88 // void DeleteCookies() { | 88 // void DeleteCookies() { |
| 89 // remover->RemoveAndReply(Unbounded(), REMOVE_COOKIES, ALL, this); | 89 // remover->RemoveAndReply(Unbounded(), REMOVE_COOKIES, ALL, this); |
| 90 // } | 90 // } |
| 91 // | 91 // |
| 92 // void OnBrowsingDataRemoverDone() { | 92 // void OnBrowsingDataRemoverDone() { |
| 93 // LOG(INFO) << "Cookies were deleted."; | 93 // LOG(INFO) << "Cookies were deleted."; |
| 94 // } | 94 // } |
| 95 // } | 95 // } |
| 96 // | 96 // |
| 97 // 3. Using an observer to report when any removal task started or all removal | |
| 98 // tasks finished (i.e. when BrowsingDataRemover changes state from idle | |
| 99 // to busy and vice versa). | |
| 100 // | |
| 101 // class BrowsingDataRemoverStatusObsever { | |
| 102 // BrowsingDataRemoverStatusObserver() { remover->AddObserver(this); } | |
| 103 // ~BrowsingDataRemoverStatusObserver() { | |
| 104 // remover->RemoveObserver(this); | |
| 105 // } | |
| 106 // | |
| 107 // void OnBrowsingDataRemoving(bool removing) { | |
| 108 // LOG(INFO) << "Remover is now " << (removing ? "busy" : "idle"); | |
| 109 // } | |
| 110 // } | |
| 111 // | |
| 112 //////////////////////////////////////////////////////////////////////////////// | 97 //////////////////////////////////////////////////////////////////////////////// |
| 113 | 98 |
| 114 class BrowsingDataRemover : public KeyedService | 99 class BrowsingDataRemover : public KeyedService |
| 115 #if defined(ENABLE_PLUGINS) | 100 #if defined(ENABLE_PLUGINS) |
| 116 , public PepperFlashSettingsManager::Client | 101 , public PepperFlashSettingsManager::Client |
| 117 #endif | 102 #endif |
| 118 { | 103 { |
| 119 public: | 104 public: |
| 120 // Mask used for Remove. | 105 // Mask used for Remove. |
| 121 enum RemoveDataMask { | 106 enum RemoveDataMask { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 }; | 176 }; |
| 192 | 177 |
| 193 struct TimeRange { | 178 struct TimeRange { |
| 194 TimeRange(base::Time begin, base::Time end) : begin(begin), end(end) {} | 179 TimeRange(base::Time begin, base::Time end) : begin(begin), end(end) {} |
| 195 bool operator==(const TimeRange& other) const; | 180 bool operator==(const TimeRange& other) const; |
| 196 | 181 |
| 197 base::Time begin; | 182 base::Time begin; |
| 198 base::Time end; | 183 base::Time end; |
| 199 }; | 184 }; |
| 200 | 185 |
| 201 // Observer is notified when the removal is active and when it's done. | 186 // Observer is notified when its own removal task is done. |
| 202 // TODO(msramek): The semantics of the two methods are slightly different; | |
| 203 // one is called for every observer at the same time, while the other only | |
| 204 // for one observer at a time. Split the interface or deprecate | |
| 205 // OnBrowsingDataRemoving(). | |
| 206 class Observer { | 187 class Observer { |
| 207 public: | 188 public: |
| 208 // NOTE: DEPRECATED; talk to dbeam/msramek before using this. | |
| 209 // | |
| 210 // Whether removal is active. Note that not having an active removal is not | |
| 211 // same as completing a removal. That is why the removing status is separate | |
| 212 // from the done message. | |
| 213 virtual void OnBrowsingDataRemoving(bool is_removing) {} | |
| 214 | |
| 215 // Called when a removal task is finished. Note that every removal task can | 189 // Called when a removal task is finished. Note that every removal task can |
| 216 // only have one observer attached to it, and only that one is called. | 190 // only have one observer attached to it, and only that one is called. |
| 217 virtual void OnBrowsingDataRemoverDone() {} | 191 virtual void OnBrowsingDataRemoverDone() = 0; |
| 218 | 192 |
| 219 protected: | 193 protected: |
| 220 virtual ~Observer() {} | 194 virtual ~Observer() {} |
| 221 }; | 195 }; |
| 222 | 196 |
| 223 // The completion inhibitor can artificially delay completion of the browsing | 197 // The completion inhibitor can artificially delay completion of the browsing |
| 224 // data removal process. It is used during testing to simulate scenarios in | 198 // data removal process. It is used during testing to simulate scenarios in |
| 225 // which the deletion stalls or takes a very long time. | 199 // which the deletion stalls or takes a very long time. |
| 226 class CompletionInhibitor { | 200 class CompletionInhibitor { |
| 227 public: | 201 public: |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 // not initialised, so the registry must be mocked out. | 556 // not initialised, so the registry must be mocked out. |
| 583 std::unique_ptr<WebappRegistry> webapp_registry_; | 557 std::unique_ptr<WebappRegistry> webapp_registry_; |
| 584 #endif | 558 #endif |
| 585 | 559 |
| 586 base::WeakPtrFactory<BrowsingDataRemover> weak_ptr_factory_; | 560 base::WeakPtrFactory<BrowsingDataRemover> weak_ptr_factory_; |
| 587 | 561 |
| 588 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemover); | 562 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemover); |
| 589 }; | 563 }; |
| 590 | 564 |
| 591 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_ | 565 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_ |
| OLD | NEW |