Index: components/offline_pages/offline_page_archiver.h |
diff --git a/components/offline_pages/offline_page_archiver.h b/components/offline_pages/offline_page_archiver.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c12bef8c2a9b5619e95cef2d8f3559e666f3f4c8 |
--- /dev/null |
+++ b/components/offline_pages/offline_page_archiver.h |
@@ -0,0 +1,64 @@ |
+// 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_ARCHIVER_H_ |
+#define COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_ARCHIVER_H_ |
+ |
+#include "base/files/file_path.h" |
+#include "url/gurl.h" |
+ |
+namespace offline_pages { |
+ |
+// Interface of a class responsible for creation of the archive for offline use. |
+class OfflinePageArchiver { |
+ public: |
+ // Represents an in progress request to archive a page. |
+ class Request { |
+ public: |
+ explicit Request(const GURL& url); |
Dmitry Titov
2015/06/12 18:09:11
It's better to leave just an interface here, witho
fgorski
2015/06/12 20:37:34
Done.
|
+ virtual ~Request(); |
+ |
+ // Cancels an in progress request to archive a page. |
+ virtual void Cancel() = 0; |
+ const GURL& url() const { return url_; } |
+ |
+ private: |
+ GURL url_; |
+ }; |
+ |
+ // Errors that will be reported when archive creation fails. |
+ enum ArchiveError { |
+ ERROR_UNKNOWN, // Don't know what went wrong. |
+ ERROR_DEVICE_FULL, // Cannot save the archive, because device is full. |
+ ERROR_CANCELLED, // Caller cancelled the request. |
+ }; |
+ |
+ // Interface of the clients that requests to archive pages. |
+ class Client { |
+ public: |
+ virtual ~Client(); |
+ |
+ // Callback called by the archiver upon successful creation of the archive. |
+ virtual void OnCreateArchiveSuccess(Request* request, |
+ const base::FilePath& file_path) = 0; |
+ // Callback called by the archiver when it fails to create the archive. |
+ virtual void OnCreateArchiveFailure(Request* request, |
+ ArchiveError error) = 0; |
+ |
+ protected: |
Dmitry Titov
2015/06/12 18:09:11
No need to have this ctor here. It is only needed
fgorski
2015/06/12 20:37:34
Done.
|
+ Client(); |
+ }; |
+ |
+ OfflinePageArchiver(); |
Dmitry Titov
2015/06/12 18:09:11
This ctor can be omitted.
fgorski
2015/06/12 20:37:34
Done.
|
+ virtual ~OfflinePageArchiver(); |
+ |
+ // Starts creating the archive. Will pass result by calling methods on the |
+ // passed in client. Caller owns the returned request object. |
Dmitry Titov
2015/06/12 18:09:11
This needs to say what happens to ongoing archivin
fgorski
2015/06/12 20:37:34
Done.
|
+ virtual scoped_ptr<Request> CreateArchive(const GURL& url, |
Dmitry Titov
2015/06/12 18:09:11
Need a comment of what happens if the same URL is
fgorski
2015/06/12 20:37:34
Archiver comes up with a name for the archive that
|
+ Client* client) = 0; |
+}; |
+ |
+} // namespace offline_pages |
+ |
+#endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_ARCHIVER_H_ |