Vectorize website settings icons in omnibox
[chromium-blink-merge.git] / components / offline_pages / offline_page_archiver.h
blob9cec07f4ba7dbd3fc015b5649ab0fb7868c6f67b
1 // Copyright 2015 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.
5 #ifndef COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_ARCHIVER_H_
6 #define COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_ARCHIVER_H_
8 #include "base/callback.h"
9 #include "base/files/file_path.h"
10 #include "base/strings/string16.h"
11 #include "url/gurl.h"
13 namespace offline_pages {
15 // Interface of a class responsible for creation of the archive for offline use.
17 // Archiver will be implemented by embedder and may have additional methods that
18 // are not interesting from the perspective of OfflinePageModel. Example of such
19 // extra information or capability is a way to enumerate available WebContents
20 // to find the one that needs to be used to create archive (or to map it to the
21 // URL passed in CreateArchive in some other way).
23 // Archiver will be responsible for naming the file that is being saved (it has
24 // URL, title and the whole page content at its disposal). For that it should be
25 // also configured with the path where the archives are stored.
27 // Archiver should be able to archive multiple pages in parallel, as these are
28 // asynchronous calls carried out by some other component.
30 // If archiver gets two consecutive requests to archive the same page (may be
31 // run in parallel) it can generate 2 different names for files and save the
32 // same page separately, as if these were 2 completely unrelated pages. It is up
33 // to the caller (e.g. OfflinePageModel) to make sure that situation like that
34 // does not happen.
36 // If the page is not completely loaded, it is up to the implementation of the
37 // archiver whether to respond with ERROR_CONTENT_UNAVAILBLE, wait longer to
38 // actually snapshot a complete page, or snapshot whatever is available at that
39 // point in time (what the user sees).
41 // TODO(fgorski): Add ability to delete archive.
42 // TODO(fgorski): Add ability to check that archive exists.
43 // TODO(fgorski): Add ability to refresh an existing archive in one step.
44 // TODO(fgorski): Add ability to identify all of the archives in the directory,
45 // to enable to model to reconcile the archives.
46 class OfflinePageArchiver {
47 public:
48 // Results of the archive creation.
49 enum class ArchiverResult {
50 SUCCESSFULLY_CREATED, // Archive created successfully.
51 ERROR_DEVICE_FULL, // Cannot save the archive - device is full.
52 ERROR_CANCELED, // Caller canceled the request.
53 ERROR_CONTENT_UNAVAILABLE, // Content to archive is not available.
54 ERROR_ARCHIVE_CREATION_FAILED, // Creation of archive failed.
57 typedef base::Callback<void(OfflinePageArchiver* /* archiver */,
58 ArchiverResult /* result */,
59 const GURL& /* url */,
60 const base::FilePath& /* file_path */,
61 int64 /* file_size */)> CreateArchiveCallback;
63 virtual ~OfflinePageArchiver() {}
65 // Starts creating the archive. Once archive is created |callback| will be
66 // called with the result and additional information.
67 virtual void CreateArchive(const CreateArchiveCallback& callback) = 0;
70 } // namespace offline_pages
72 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_ARCHIVER_H_