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

Side by Side Diff: content/browser/download/save_package.h

Issue 1373573002: ABANDONED: OOPIFs: Moving stitching of local paths from renderer to browser process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@page-serialization-recursive-begone
Patch Set: Self-review. Created 5 years, 2 months 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 CONTENT_BROWSER_DOWNLOAD_SAVE_PACKAGE_H_ 5 #ifndef CONTENT_BROWSER_DOWNLOAD_SAVE_PACKAGE_H_
6 #define CONTENT_BROWSER_DOWNLOAD_SAVE_PACKAGE_H_ 6 #define CONTENT_BROWSER_DOWNLOAD_SAVE_PACKAGE_H_
7 7
8 #include <map>
8 #include <queue> 9 #include <queue>
9 #include <set> 10 #include <set>
10 #include <string> 11 #include <string>
11 #include <vector> 12 #include <vector>
12 13
13 #include "base/basictypes.h" 14 #include "base/basictypes.h"
14 #include "base/containers/hash_tables.h" 15 #include "base/containers/hash_tables.h"
15 #include "base/files/file_path.h" 16 #include "base/files/file_path.h"
16 #include "base/gtest_prod_util.h" 17 #include "base/gtest_prod_util.h"
17 #include "base/memory/ref_counted.h" 18 #include "base/memory/ref_counted.h"
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 void GetSavableResourceLinksForFrame(RenderFrameHost* target); 183 void GetSavableResourceLinksForFrame(RenderFrameHost* target);
183 void OnSavableResourceLinksResponse( 184 void OnSavableResourceLinksResponse(
184 RenderFrameHost* sender, 185 RenderFrameHost* sender,
185 const GURL& frame_url, 186 const GURL& frame_url,
186 const std::vector<GURL>& resources_list, 187 const std::vector<GURL>& resources_list,
187 const std::vector<Referrer>& referrers_list); 188 const std::vector<Referrer>& referrers_list);
188 void OnSavableResourceLinksError(RenderFrameHost* sender); 189 void OnSavableResourceLinksError(RenderFrameHost* sender);
189 void CompleteSavableResourceLinksResponse(); 190 void CompleteSavableResourceLinksResponse();
190 191
191 // Ask renderer processes to serialize all frames in the current page. 192 // Ask renderer processes to serialize all frames in the current page.
193 // (serialize into html data with "blanks" that we can replace with links to
194 // local paths).
192 void GetSerializedHtmlWithLocalLinks(); 195 void GetSerializedHtmlWithLocalLinks();
193 196
194 // Ask renderer process to serialize |target| frame into html data 197 // Equivalent of GetSerializedHtmlWithLocalLinks that targets a single
195 // with lists which contain all resource links that have a local copy. 198 // |target| frame.
196 // The parameter |saved_links| contains original URLs of all saved links. 199 void GetSerializedHtmlWithLocalLinksForFrame(RenderFrameHost* target);
197 // The parameter |saved_file_paths| contains corresponding local file paths of
198 // all saved links, which is matched with vector:links one by one.
199 // The parameter |relative_dir_name| is relative path of directory which
200 // contain all saved auxiliary files included all sub frames and resouces.
201 void GetSerializedHtmlWithLocalLinksForFrame(
202 const std::vector<GURL>& saved_links,
203 const std::vector<base::FilePath>& saved_file_paths,
204 const base::FilePath& relative_dir_name,
205 RenderFrameHost* target);
206 200
207 // Routes html data (sent by renderer process in response to 201 // Response to GetSerializedHtmlWithLocalLinksForFrame above that routes html
208 // GetSerializedHtmlWithLocalLinksForFrame above) to the associated local file 202 // fragment into the local file associated with |sender|.
209 // (and also keeps track of when all frames have been completed). 203 void OnSerializedHtmlFragment(RenderFrameHost* sender,
210 void OnSerializedHtmlWithLocalLinksResponse(RenderFrameHost* sender, 204 const std::string& data);
211 const GURL& frame_url, 205
212 const std::string& data, 206 // Response to GetSerializedHtmlWithLocalLinksForFrame above that replaces
213 int32 status); 207 // |render_frame_or_proxy_routing_id| with a corresponding local path
208 // and then writes the result to the local file associated with |sender|.
209 void OnSerializedLocalPathForSubFrame(RenderFrameHost* sender,
210 int render_frame_or_proxy_routing_id);
211
212 // Response to GetSerializedHtmlWithLocalLinksForFrame above that replaces
213 // |savable_resource| with a corresponding local path and then writes the
214 // result to the local file associated with |sender|.
215 void OnSerializedLocalPathForSavableResource(RenderFrameHost* sender,
216 const GURL& savable_resource);
217
218 // Response to GetSerializedHtmlWithLocalLinksForFrame above that keeps track
219 // of how many frames still need to complete their serialization process.
220 void OnSerializedEndOfFrame(RenderFrameHost* sender);
221
222 // Helper used by OnSerializedLocalPathForSubFrame and
223 // OnSerializedLocalPathForSavableResource to convert |save_item| into a local
224 // path (and falling back to |fallback_url| if |save_item| is null).
225 void SerializeLocalPathForSaveItem(RenderFrameHost* sender,
226 SaveItem* save_item,
227 const GURL& fallback_url);
228
229 // Finds in-progress SaveItem by |frame_tree_node_id|.
230 SaveItem* FindInProgressSaveItemByFrameTreeNodeID(int frame_tree_node_id);
231
232 // Helper to log telemetry entry for writes to already completed or failed
233 // SaveItems.
234 void LogWriteToAlreadyCompletedOrFailedSaveItem(int frame_tree_node_id);
214 235
215 // Look up SaveItem by save id from in progress map. 236 // Look up SaveItem by save id from in progress map.
216 SaveItem* LookupItemInProcessBySaveId(int32 save_id); 237 SaveItem* LookupItemInProcessBySaveId(int32 save_id);
217 238
218 // Remove SaveItem from in progress map and put it to saved map. 239 // Remove SaveItem from in progress map and put it to saved map.
219 void PutInProgressItemToSavedMap(SaveItem* save_item); 240 void PutInProgressItemToSavedMap(SaveItem* save_item);
220 241
221 // Retrieves the URL to be saved from the WebContents. 242 // Retrieves the URL to be saved from the WebContents.
222 GURL GetUrlToBeSaved(); 243 GURL GetUrlToBeSaved();
223 244
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 297
277 // Returns extension for supported MIME types (for example, for "text/plain" 298 // Returns extension for supported MIME types (for example, for "text/plain"
278 // it returns "txt"). 299 // it returns "txt").
279 static const base::FilePath::CharType* ExtensionForMimeType( 300 static const base::FilePath::CharType* ExtensionForMimeType(
280 const std::string& contents_mime_type); 301 const std::string& contents_mime_type);
281 302
282 typedef std::queue<SaveItem*> SaveItemQueue; 303 typedef std::queue<SaveItem*> SaveItemQueue;
283 // A queue for items we are about to start saving. 304 // A queue for items we are about to start saving.
284 SaveItemQueue waiting_item_queue_; 305 SaveItemQueue waiting_item_queue_;
285 306
286 // Used to de-dupe urls that are being gathered into |waiting_item_queue_|. 307 // Used to
287 std::set<GURL> unique_urls_to_save_; 308 // 1) de-dupe urls that are being gathered into |waiting_item_queue_|
288 309 // 2) find a SaveItem which needs to be updated with frame_tree_node_id or
289 // Temporarily stores urls of savable frames, until we can process them. 310 // referrer.
290 std::vector<GURL> frame_urls_to_save_; 311 std::map<GURL, SaveItem*> url_to_save_item_;
291 312
292 // Number of frames that we still need to get a response from. 313 // Number of frames that we still need to get a response from.
293 int number_of_frames_pending_response_; 314 int number_of_frames_pending_response_;
294 315
295 typedef base::hash_map<int32, SaveItem*> SavedItemMap; 316 typedef base::hash_map<int32, SaveItem*> SavedItemMap;
296 // saved_success_items_ is map of all saving job which are successfully saved. 317 // saved_success_items_ is map of all saving job which are successfully saved.
297 SavedItemMap saved_success_items_; 318 SavedItemMap saved_success_items_;
298 319
299 // Non-owning pointer for handling file writing on the file thread. 320 // Non-owning pointer for handling file writing on the file thread.
300 SaveFileManager* file_manager_; 321 SaveFileManager* file_manager_;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 friend class SavePackageTest; 383 friend class SavePackageTest;
363 FRIEND_TEST_ALL_PREFIXES(SavePackageTest, TestSuggestedSaveNames); 384 FRIEND_TEST_ALL_PREFIXES(SavePackageTest, TestSuggestedSaveNames);
364 FRIEND_TEST_ALL_PREFIXES(SavePackageTest, TestLongSafePureFilename); 385 FRIEND_TEST_ALL_PREFIXES(SavePackageTest, TestLongSafePureFilename);
365 386
366 DISALLOW_COPY_AND_ASSIGN(SavePackage); 387 DISALLOW_COPY_AND_ASSIGN(SavePackage);
367 }; 388 };
368 389
369 } // namespace content 390 } // namespace content
370 391
371 #endif // CONTENT_BROWSER_DOWNLOAD_SAVE_PACKAGE_H_ 392 #endif // CONTENT_BROWSER_DOWNLOAD_SAVE_PACKAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698