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

Side by Side Diff: ios/chrome/browser/reading_list/url_downloader.h

Issue 2491383002: Use Distilled path instead of DistilledURL. (Closed)
Patch Set: fix compilation Created 4 years, 1 month 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef IOS_CHROME_BROWSER_READING_LIST_URL_DOWNLOADER_H_ 5 #ifndef IOS_CHROME_BROWSER_READING_LIST_URL_DOWNLOADER_H_
6 #define IOS_CHROME_BROWSER_READING_LIST_URL_DOWNLOADER_H_ 6 #define IOS_CHROME_BROWSER_READING_LIST_URL_DOWNLOADER_H_
7 7
8 #include <queue> 8 #include <queue>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 27 matching lines...) Expand all
38 ERROR_RETRY, 38 ERROR_RETRY,
39 ERROR_PERMANENT 39 ERROR_PERMANENT
40 }; 40 };
41 41
42 // A completion callback that takes a GURL and a bool indicating the 42 // A completion callback that takes a GURL and a bool indicating the
43 // outcome and returns void. 43 // outcome and returns void.
44 using SuccessCompletion = base::Callback<void(const GURL&, bool)>; 44 using SuccessCompletion = base::Callback<void(const GURL&, bool)>;
45 45
46 // A download completion callback that takes, in order, the GURL that was 46 // A download completion callback that takes, in order, the GURL that was
47 // downloaded, a SuccessState indicating the outcome of the download, the 47 // downloaded, a SuccessState indicating the outcome of the download, the
48 // offline GURL for the download, and the title of the url, and returns void. 48 // path to the downloaded page (relative to |OfflineRootDirectoryPath()|, and
49 // The offline GURL and title should not be used in case of failure. 49 // the title of the url, and returns void.
50 using DownloadCompletion = base::Callback< 50 // The path to downloaded file and title should not be used in case of
51 void(const GURL&, SuccessState, const GURL&, const std::string&)>; 51 // failure.
52 using DownloadCompletion = base::Callback<void(const GURL&,
53 SuccessState,
54 const base::FilePath&,
55 const std::string&)>;
52 56
53 // Create a URL downloader with completion callbacks for downloads and 57 // Create a URL downloader with completion callbacks for downloads and
54 // deletions. The completion callbacks will be called with the original url 58 // deletions. The completion callbacks will be called with the original url
55 // and a boolean indicating success. For downloads, if distillation was 59 // and a boolean indicating success. For downloads, if distillation was
56 // successful, it will also include the distilled url and extracted title. 60 // successful, it will also include the distilled url and extracted title.
57 URLDownloader(dom_distiller::DomDistillerService* distiller_service, 61 URLDownloader(dom_distiller::DomDistillerService* distiller_service,
58 PrefService* prefs, 62 PrefService* prefs,
59 base::FilePath chrome_profile_path, 63 base::FilePath chrome_profile_path,
60 const DownloadCompletion& download_completion, 64 const DownloadCompletion& download_completion,
61 const SuccessCompletion& delete_completion); 65 const SuccessCompletion& delete_completion);
(...skipping 14 matching lines...) Expand all
76 // Handles the next task in the queue, if no task is currently being handled. 80 // Handles the next task in the queue, if no task is currently being handled.
77 void HandleNextTask(); 81 void HandleNextTask();
78 // Callback for completed (or failed) download, handles calling 82 // Callback for completed (or failed) download, handles calling
79 // downloadCompletion and starting the next task. 83 // downloadCompletion and starting the next task.
80 void DownloadCompletionHandler(const GURL& url, 84 void DownloadCompletionHandler(const GURL& url,
81 const std::string& title, 85 const std::string& title,
82 SuccessState success); 86 SuccessState success);
83 // Callback for completed (or failed) deletion, handles calling 87 // Callback for completed (or failed) deletion, handles calling
84 // deleteCompletion and starting the next task. 88 // deleteCompletion and starting the next task.
85 void DeleteCompletionHandler(const GURL& url, bool success); 89 void DeleteCompletionHandler(const GURL& url, bool success);
86 // The path of the directory where offline URLs are saved. 90 // The absolute path of the directory where offline URLs are saved.
87 base::FilePath OfflineDirectoryPath(); 91 base::FilePath OfflineRootDirectoryPath();
88 // The path of the directory where a specific URL is saved offline. Contains 92
89 // the page and supporting files (images). 93 // The absolute path of the directory where a specific URL is saved offline.
90 base::FilePath OfflineURLDirectoryPath(const GURL& url); 94 // Contains the page and supporting files (images).
91 // The path of the offline webpage for the URL. The file may not exist. 95 base::FilePath OfflineURLDirectoryAbsolutePath(const GURL& url);
92 base::FilePath OfflineURLPagePath(const GURL& url); 96 // The absolute path of the offline webpage for the URL. The file may not
97 // exist.
98 base::FilePath OfflinePageAbsolutePath(const GURL& url);
99 // The relative path to the distilled page. The result is relative to
100 // |OfflineRootDirectoryPath()|.
101 base::FilePath OfflinePagePath(const GURL& url);
93 // Creates the offline directory for |url|. Returns true if successful or if 102 // Creates the offline directory for |url|. Returns true if successful or if
94 // the directory already exists. 103 // the directory already exists.
95 bool CreateOfflineURLDirectory(const GURL& url); 104 bool CreateOfflineURLDirectory(const GURL& url);
105 // The name of the directory containing offline data for |url|.
106 std::string OfflineURLDirectoryID(const GURL& url);
107
96 // Saves the |data| for image at |imageURL| to disk, for main URL |url|; 108 // Saves the |data| for image at |imageURL| to disk, for main URL |url|;
97 // puts path of saved file in |path| and returns whether save was successful. 109 // puts path of saved file in |path| and returns whether save was successful.
98 bool SaveImage(const GURL& url, 110 bool SaveImage(const GURL& url,
99 const GURL& imageURL, 111 const GURL& imageURL,
100 const std::string& data, 112 const std::string& data,
101 std::string* image_name); 113 std::string* image_name);
102 // Saves images in |images| array to disk and replaces references in |html| to 114 // Saves images in |images| array to disk and replaces references in |html| to
103 // local path. Returns updated html. 115 // local path. Returns updated html.
104 std::string SaveAndReplaceImagesInHTML( 116 std::string SaveAndReplaceImagesInHTML(
105 const GURL& url, 117 const GURL& url,
(...skipping 25 matching lines...) Expand all
131 std::deque<Task> tasks_; 143 std::deque<Task> tasks_;
132 bool working_; 144 bool working_;
133 base::FilePath base_directory_; 145 base::FilePath base_directory_;
134 std::unique_ptr<dom_distiller::DistillerViewerInterface> distiller_; 146 std::unique_ptr<dom_distiller::DistillerViewerInterface> distiller_;
135 base::CancelableTaskTracker task_tracker_; 147 base::CancelableTaskTracker task_tracker_;
136 148
137 DISALLOW_COPY_AND_ASSIGN(URLDownloader); 149 DISALLOW_COPY_AND_ASSIGN(URLDownloader);
138 }; 150 };
139 151
140 #endif // IOS_CHROME_BROWSER_READING_LIST_URL_DOWNLOADER_H_ 152 #endif // IOS_CHROME_BROWSER_READING_LIST_URL_DOWNLOADER_H_
OLDNEW
« no previous file with comments | « ios/chrome/browser/reading_list/reading_list_model_unittest.cc ('k') | ios/chrome/browser/reading_list/url_downloader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698