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