summaryrefslogtreecommitdiffstats
path: root/components/offline_pages/offline_page_metadata_store.h
blob: 4e096a8aab9e1b020eebcf44223c09cd55a473b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_METADATA_STORE_H_
#define COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_METADATA_STORE_H_

#include <vector>

#include "base/callback.h"

class GURL;

namespace offline_pages {

struct OfflinePageItem;

// OfflinePageMetadataStore keeps metadata for the offline pages.
// Ability to create multiple instances of the store as well as behavior of
// asynchronous operations when the object is being destroyed, before such
// operation finishes will depend on implementation. It should be possible to
// issue multiple asynchronous operations in parallel.
class OfflinePageMetadataStore {
 public:
  typedef base::Callback<void(bool, const std::vector<OfflinePageItem>&)>
      LoadCallback;
  typedef base::Callback<void(bool)> UpdateCallback;

  OfflinePageMetadataStore();
  virtual ~OfflinePageMetadataStore();

  // Get all of the offline pages from the store.
  virtual void Load(const LoadCallback& callback) = 0;

  // Asynchronously adds offline page metadata to the store for a given URL.
  // Result of the update is passed in callback.
  virtual void AddOfflinePage(const OfflinePageItem& offline_page,
                              const UpdateCallback& callback) = 0;

  // Asynchronously removes offline page metadata from the store.
  // Result of the update is passed in callback.
  virtual void RemoveOfflinePage(const GURL& page_url,
                                 const UpdateCallback& callback) = 0;
};

}  // namespace offline_pages

#endif  // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_METADATA_STORE_H_