OLD | NEW |
(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 "base/files/file_path.h" |
| 9 #include "url/gurl.h" |
| 10 |
| 11 namespace offline_pages { |
| 12 |
| 13 // Interface of a class responsible for creation of the archive for offline use. |
| 14 class OfflinePageArchiver { |
| 15 public: |
| 16 // Represents an in progress request to archive a page. |
| 17 class Request { |
| 18 public: |
| 19 virtual ~Request(); |
| 20 |
| 21 // Cancels an in progress request to archive a page. |
| 22 virtual void Cancel() = 0; |
| 23 virtual const GURL& url() const = 0; |
| 24 }; |
| 25 |
| 26 // Errors that will be reported when archive creation fails. |
| 27 enum ArchiveError { |
| 28 ERROR_UNKNOWN, // Don't know what went wrong. |
| 29 ERROR_DEVICE_FULL, // Cannot save the archive - device is full. |
| 30 ERROR_CANCELLED, // Caller cancelled the request. |
| 31 ERROR_CONTENT_UNAVAILABLE, // Content to archive is not available. |
| 32 }; |
| 33 |
| 34 // Interface of the clients that requests to archive pages. |
| 35 class Client { |
| 36 public: |
| 37 virtual ~Client(); |
| 38 |
| 39 // Callback called by the archiver upon successful creation of the archive. |
| 40 virtual void OnCreateArchiveSuccess(Request* request, |
| 41 const base::FilePath& file_path) = 0; |
| 42 // Callback called by the archiver when it fails to create the archive. |
| 43 virtual void OnCreateArchiveFailure(Request* request, |
| 44 ArchiveError error) = 0; |
| 45 }; |
| 46 |
| 47 virtual ~OfflinePageArchiver(); |
| 48 |
| 49 // Starts creating the archive. Will pass result by calling methods on the |
| 50 // passed in client. Caller owns the returned request object. |
| 51 // If request is deleted during the archiving, the callback will not be |
| 52 // invoked. The archive might however be created. |
| 53 virtual scoped_ptr<Request> CreateArchive(const GURL& url, |
| 54 Client* client) = 0; |
| 55 }; |
| 56 |
| 57 } // namespace offline_pages |
| 58 |
| 59 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_ARCHIVER_H_ |
OLD | NEW |