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 #include "chrome/browser/browsing_data/mock_browsing_data_indexed_db_helper.h" | 5 #include "chrome/browser/browsing_data/mock_browsing_data_indexed_db_helper.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 | 9 |
10 MockBrowsingDataIndexedDBHelper::MockBrowsingDataIndexedDBHelper() { | 10 MockBrowsingDataIndexedDBHelper::MockBrowsingDataIndexedDBHelper() { |
11 } | 11 } |
12 | 12 |
13 MockBrowsingDataIndexedDBHelper::~MockBrowsingDataIndexedDBHelper() { | 13 MockBrowsingDataIndexedDBHelper::~MockBrowsingDataIndexedDBHelper() { |
14 } | 14 } |
15 | 15 |
16 void MockBrowsingDataIndexedDBHelper::StartFetching( | 16 void MockBrowsingDataIndexedDBHelper::StartFetching( |
17 const base::Callback<void(const std::list<IndexedDBInfo>&)>& callback) { | 17 const base::Callback<void(const std::list<content::IndexedDBInfo>&)>& |
| 18 callback) { |
18 callback_ = callback; | 19 callback_ = callback; |
19 } | 20 } |
20 | 21 |
21 void MockBrowsingDataIndexedDBHelper::DeleteIndexedDB( | 22 void MockBrowsingDataIndexedDBHelper::DeleteIndexedDB( |
22 const GURL& origin) { | 23 const GURL& origin) { |
23 CHECK(origins_.find(origin) != origins_.end()); | 24 CHECK(origins_.find(origin) != origins_.end()); |
24 origins_[origin] = false; | 25 origins_[origin] = false; |
25 } | 26 } |
26 | 27 |
27 void MockBrowsingDataIndexedDBHelper::AddIndexedDBSamples() { | 28 void MockBrowsingDataIndexedDBHelper::AddIndexedDBSamples() { |
28 const GURL kOrigin1("http://idbhost1:1/"); | 29 const GURL kOrigin1("http://idbhost1:1/"); |
29 const GURL kOrigin2("http://idbhost2:2/"); | 30 const GURL kOrigin2("http://idbhost2:2/"); |
30 response_.push_back( | 31 content::IndexedDBInfo info1(kOrigin1, 1, base::Time()); |
31 BrowsingDataIndexedDBHelper::IndexedDBInfo( | 32 response_.push_back(info1); |
32 kOrigin1, 1, base::Time())); | |
33 origins_[kOrigin1] = true; | 33 origins_[kOrigin1] = true; |
34 response_.push_back( | 34 content::IndexedDBInfo info2(kOrigin2, 2, base::Time()); |
35 BrowsingDataIndexedDBHelper::IndexedDBInfo( | 35 response_.push_back(info2); |
36 kOrigin2, 2, base::Time())); | |
37 origins_[kOrigin2] = true; | 36 origins_[kOrigin2] = true; |
38 } | 37 } |
39 | 38 |
40 void MockBrowsingDataIndexedDBHelper::Notify() { | 39 void MockBrowsingDataIndexedDBHelper::Notify() { |
41 CHECK_EQ(false, callback_.is_null()); | 40 CHECK_EQ(false, callback_.is_null()); |
42 callback_.Run(response_); | 41 callback_.Run(response_); |
43 } | 42 } |
44 | 43 |
45 void MockBrowsingDataIndexedDBHelper::Reset() { | 44 void MockBrowsingDataIndexedDBHelper::Reset() { |
46 for (std::map<GURL, bool>::iterator i = origins_.begin(); | 45 for (std::map<GURL, bool>::iterator i = origins_.begin(); |
47 i != origins_.end(); ++i) | 46 i != origins_.end(); ++i) |
48 i->second = true; | 47 i->second = true; |
49 } | 48 } |
50 | 49 |
51 bool MockBrowsingDataIndexedDBHelper::AllDeleted() { | 50 bool MockBrowsingDataIndexedDBHelper::AllDeleted() { |
52 for (std::map<GURL, bool>::const_iterator i = origins_.begin(); | 51 for (std::map<GURL, bool>::const_iterator i = origins_.begin(); |
53 i != origins_.end(); ++i) | 52 i != origins_.end(); ++i) |
54 if (i->second) | 53 if (i->second) |
55 return false; | 54 return false; |
56 return true; | 55 return true; |
57 } | 56 } |
OLD | NEW |