OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/mock_browsing_data_local_storage_helper.h" | |
6 | |
7 #include "base/callback.h" | |
8 #include "base/logging.h" | |
9 | |
10 MockBrowsingDataLocalStorageHelper::MockBrowsingDataLocalStorageHelper( | |
11 Profile* profile) | |
12 : BrowsingDataLocalStorageHelper(profile) { | |
13 } | |
14 | |
15 MockBrowsingDataLocalStorageHelper::~MockBrowsingDataLocalStorageHelper() { | |
16 } | |
17 | |
18 void MockBrowsingDataLocalStorageHelper::StartFetching( | |
19 const base::Callback<void(const std::list<LocalStorageInfo>&)>& callback) { | |
20 callback_ = callback; | |
21 } | |
22 | |
23 void MockBrowsingDataLocalStorageHelper::DeleteOrigin( | |
24 const GURL& origin) { | |
25 CHECK(origins_.find(origin) != origins_.end()); | |
26 last_deleted_origin_ = origin; | |
27 origins_[origin] = false; | |
28 } | |
29 | |
30 void MockBrowsingDataLocalStorageHelper::AddLocalStorageSamples() { | |
31 const GURL kOrigin1("http://host1:1/"); | |
32 const GURL kOrigin2("http://host2:2/"); | |
33 response_.push_back( | |
34 BrowsingDataLocalStorageHelper::LocalStorageInfo( | |
35 kOrigin1, 1, base::Time())); | |
36 origins_[kOrigin1] = true; | |
37 response_.push_back( | |
38 BrowsingDataLocalStorageHelper::LocalStorageInfo( | |
39 kOrigin2, 2, base::Time())); | |
40 origins_[kOrigin2] = true; | |
41 } | |
42 | |
43 void MockBrowsingDataLocalStorageHelper::Notify() { | |
44 CHECK_EQ(false, callback_.is_null()); | |
45 callback_.Run(response_); | |
46 } | |
47 | |
48 void MockBrowsingDataLocalStorageHelper::Reset() { | |
49 for (std::map<const GURL, bool>::iterator i = origins_.begin(); | |
50 i != origins_.end(); ++i) | |
51 i->second = true; | |
52 } | |
53 | |
54 bool MockBrowsingDataLocalStorageHelper::AllDeleted() { | |
55 for (std::map<const GURL, bool>::const_iterator i = | |
56 origins_.begin(); i != origins_.end(); ++i) | |
57 if (i->second) | |
58 return false; | |
59 return true; | |
60 } | |
OLD | NEW |