1// Copyright 2014 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_BROWSING_DATA_MOCK_BROWSING_DATA_SERVICE_WORKER_HELPER_H_
6#define CHROME_BROWSER_BROWSING_DATA_MOCK_BROWSING_DATA_SERVICE_WORKER_HELPER_H_
7
8#include <list>
9#include <map>
10
11#include "base/callback.h"
12#include "base/compiler_specific.h"
13#include "chrome/browser/browsing_data/browsing_data_service_worker_helper.h"
14
15class Profile;
16
17// Mock for BrowsingDataServiceWorkerHelper.
18// Use AddServiceWorkerSamples() or add directly to response_ list, then
19// call Notify().
20class MockBrowsingDataServiceWorkerHelper
21    : public BrowsingDataServiceWorkerHelper {
22 public:
23  explicit MockBrowsingDataServiceWorkerHelper(Profile* profile);
24
25  // Adds some ServiceWorkerInfo samples.
26  void AddServiceWorkerSamples();
27
28  // Notifies the callback.
29  void Notify();
30
31  // Marks all service worker files as existing.
32  void Reset();
33
34  // Returns true if all service worker files were deleted since the last
35  // Reset() invokation.
36  bool AllDeleted();
37
38  // BrowsingDataServiceWorkerHelper.
39  virtual void StartFetching(const base::Callback<void(
40      const std::list<content::ServiceWorkerUsageInfo>&)>& callback) OVERRIDE;
41  virtual void DeleteServiceWorkers(const GURL& origin) OVERRIDE;
42
43 private:
44  virtual ~MockBrowsingDataServiceWorkerHelper();
45
46  base::Callback<void(const std::list<content::ServiceWorkerUsageInfo>&)>
47      callback_;
48  std::map<GURL, bool> origins_;
49  std::list<content::ServiceWorkerUsageInfo> response_;
50
51  DISALLOW_COPY_AND_ASSIGN(MockBrowsingDataServiceWorkerHelper);
52};
53
54#endif  // CHROME_BROWSER_BROWSING_DATA_MOCK_BROWSING_DATA_SERVICE_WORKER_HELPER_H_
55