Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: components/offline_pages/offline_page_archiver.h

Issue 2489443002: Move all components/offline_pages/ files into component/offline_pages/core (Closed)
Patch Set: rebase Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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.
4
5 #ifndef COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_ARCHIVER_H_
6 #define COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_ARCHIVER_H_
7
8 #include <stdint.h>
9
10 #include "base/callback.h"
11 #include "base/files/file_path.h"
12 #include "base/strings/string16.h"
13 #include "url/gurl.h"
14
15 namespace offline_pages {
16
17 // Interface of a class responsible for creation of the archive for offline use.
18 //
19 // Archiver will be implemented by embedder and may have additional methods that
20 // are not interesting from the perspective of OfflinePageModel. Example of such
21 // extra information or capability is a way to enumerate available WebContents
22 // to find the one that needs to be used to create archive (or to map it to the
23 // URL passed in CreateArchive in some other way).
24 //
25 // Archiver will be responsible for naming the file that is being saved (it has
26 // URL, title and the whole page content at its disposal). For that it should be
27 // also configured with the path where the archives are stored.
28 //
29 // Archiver should be able to archive multiple pages in parallel, as these are
30 // asynchronous calls carried out by some other component.
31 //
32 // If archiver gets two consecutive requests to archive the same page (may be
33 // run in parallel) it can generate 2 different names for files and save the
34 // same page separately, as if these were 2 completely unrelated pages. It is up
35 // to the caller (e.g. OfflinePageModel) to make sure that situation like that
36 // does not happen.
37 //
38 // If the page is not completely loaded, it is up to the implementation of the
39 // archiver whether to respond with ERROR_CONTENT_UNAVAILBLE, wait longer to
40 // actually snapshot a complete page, or snapshot whatever is available at that
41 // point in time (what the user sees).
42 //
43 // TODO(fgorski): Add ability to delete archive.
44 // TODO(fgorski): Add ability to check that archive exists.
45 // TODO(fgorski): Add ability to refresh an existing archive in one step.
46 // TODO(fgorski): Add ability to identify all of the archives in the directory,
47 // to enable to model to reconcile the archives.
48 class OfflinePageArchiver {
49 public:
50 // Results of the archive creation.
51 enum class ArchiverResult {
52 SUCCESSFULLY_CREATED, // Archive created successfully.
53 ERROR_DEVICE_FULL, // Cannot save the archive - device is full.
54 ERROR_CANCELED, // Caller canceled the request.
55 ERROR_CONTENT_UNAVAILABLE, // Content to archive is not available.
56 ERROR_ARCHIVE_CREATION_FAILED, // Creation of archive failed.
57 ERROR_SECURITY_CERTIFICATE, // Page was loaded on secure connection, but
58 // there was a security error.
59 };
60
61 typedef base::Callback<void(OfflinePageArchiver* /* archiver */,
62 ArchiverResult /* result */,
63 const GURL& /* url */,
64 const base::FilePath& /* file_path */,
65 const base::string16& /* title */,
66 int64_t /* file_size */)>
67 CreateArchiveCallback;
68
69 virtual ~OfflinePageArchiver() {}
70
71 // Starts creating the archive in the |archives_dir| with |archive_id| added
72 // to the archive filename. Once archive is created |callback| will be called
73 // with the result and additional information.
74 virtual void CreateArchive(const base::FilePath& archives_dir,
75 int64_t archive_id,
76 const CreateArchiveCallback& callback) = 0;
77 };
78
79 } // namespace offline_pages
80
81 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_ARCHIVER_H_
OLDNEW
« no previous file with comments | « components/offline_pages/offline_event_logger.cc ('k') | components/offline_pages/offline_page_client_policy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698