1// Copyright (c) 2010 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#ifndef CHROME_BROWSER_MOCK_BROWSING_DATA_LOCAL_STORAGE_HELPER_H_ 6#define CHROME_BROWSER_MOCK_BROWSING_DATA_LOCAL_STORAGE_HELPER_H_ 7#pragma once 8 9#include <map> 10#include <vector> 11 12#include "base/callback.h" 13#include "chrome/browser/browsing_data_local_storage_helper.h" 14 15// Mock for BrowsingDataLocalStorageHelper. 16// Use AddLocalStorageSamples() or add directly to response_ vector, then 17// call Notify(). 18class MockBrowsingDataLocalStorageHelper 19 : public BrowsingDataLocalStorageHelper { 20 public: 21 explicit MockBrowsingDataLocalStorageHelper(Profile* profile); 22 23 virtual void StartFetching( 24 Callback1<const std::vector<LocalStorageInfo>& >::Type* callback); 25 26 virtual void CancelNotification(); 27 28 virtual void DeleteLocalStorageFile(const FilePath& file_path); 29 30 // Adds some LocalStorageInfo samples. 31 void AddLocalStorageSamples(); 32 33 // Notifies the callback. 34 void Notify(); 35 36 // Marks all local storage files as existing. 37 void Reset(); 38 39 // Returns true if all local storage files were deleted since the last 40 // Reset() invokation. 41 bool AllDeleted(); 42 43 FilePath last_deleted_file_; 44 45 private: 46 virtual ~MockBrowsingDataLocalStorageHelper(); 47 48 Profile* profile_; 49 50 scoped_ptr<Callback1<const std::vector<LocalStorageInfo>& >::Type > 51 callback_; 52 53 std::map<const FilePath::StringType, bool> files_; 54 55 std::vector<LocalStorageInfo> response_; 56}; 57 58#endif // CHROME_BROWSER_MOCK_BROWSING_DATA_LOCAL_STORAGE_HELPER_H_ 59