1// Copyright (c) 2009 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 10MockBrowsingDataLocalStorageHelper::MockBrowsingDataLocalStorageHelper( 11 Profile* profile) 12 : BrowsingDataLocalStorageHelper(profile), 13 profile_(profile) { 14} 15 16MockBrowsingDataLocalStorageHelper::~MockBrowsingDataLocalStorageHelper() { 17} 18 19void MockBrowsingDataLocalStorageHelper::StartFetching( 20 Callback1<const std::vector<LocalStorageInfo>& >::Type* callback) { 21 callback_.reset(callback); 22} 23 24void MockBrowsingDataLocalStorageHelper::CancelNotification() { 25 callback_.reset(NULL); 26} 27 28void MockBrowsingDataLocalStorageHelper::DeleteLocalStorageFile( 29 const FilePath& file_path) { 30 CHECK(files_.find(file_path.value()) != files_.end()); 31 last_deleted_file_ = file_path; 32 files_[file_path.value()] = false; 33} 34 35void MockBrowsingDataLocalStorageHelper::AddLocalStorageSamples() { 36 response_.push_back( 37 BrowsingDataLocalStorageHelper::LocalStorageInfo( 38 "http", "host1", 1, "db1", "http://host1:1/", 39 FilePath(FILE_PATH_LITERAL("file1")), 1, base::Time())); 40 files_[FILE_PATH_LITERAL("file1")] = true; 41 response_.push_back( 42 BrowsingDataLocalStorageHelper::LocalStorageInfo( 43 "http", "host2", 2, "db2", "http://host2:2/", 44 FilePath(FILE_PATH_LITERAL("file2")), 2, base::Time())); 45 files_[FILE_PATH_LITERAL("file2")] = true; 46} 47 48void MockBrowsingDataLocalStorageHelper::Notify() { 49 CHECK(callback_.get()); 50 callback_->Run(response_); 51} 52 53void MockBrowsingDataLocalStorageHelper::Reset() { 54 for (std::map<const FilePath::StringType, bool>::iterator i = files_.begin(); 55 i != files_.end(); ++i) 56 i->second = true; 57} 58 59bool MockBrowsingDataLocalStorageHelper::AllDeleted() { 60 for (std::map<const FilePath::StringType, bool>::const_iterator i = 61 files_.begin(); i != files_.end(); ++i) 62 if (i->second) 63 return false; 64 return true; 65} 66