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