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

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: Rebasing... 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 // For each frame in the current page, ask the renderer process associated 192 // For each frame in the current page, ask the renderer process associated
192 // with that frame to serialize that frame into html. 193 // with that frame to serialize that frame into html (serialize into html with
194 // "blanks" that we can replace with links to local paths).
193 void GetSerializedHtmlWithLocalLinks(); 195 void GetSerializedHtmlWithLocalLinks();
194 196
195 // Ask renderer process to serialize |target| frame into html data 197 // Equivalent of GetSerializedHtmlWithLocalLinks that targets a single
196 // with lists which contain all resource links that have a local copy. 198 // |target| frame.
197 // - The parameter |saved_links| contains original URLs of all saved links 199 void GetSerializedHtmlWithLocalLinksForFrame(RenderFrameHost* target);
198 // (which may include URLs referred to from the whole page (not just from
199 // the |target| frame).
200 // - The parameter |saved_file_paths| contains corresponding local file paths
201 // of all saved links, which is matched with |saved_links| vector one by
202 // one.
203 // - The parameter |relative_dir_name| is relative path of directory which
204 // contain all saved auxiliary files included all sub frames and resouces.
205 void GetSerializedHtmlWithLocalLinksForFrame(
206 const std::vector<GURL>& saved_links,
207 const std::vector<base::FilePath>& saved_file_paths,
208 const base::FilePath& relative_dir_name,
209 RenderFrameHost* target);
210 200
211 // Routes html data (sent by renderer process in response to 201 // Response to GetSerializedHtmlWithLocalLinksForFrame above that routes html
212 // GetSerializedHtmlWithLocalLinksForFrame above) to the associated local file 202 // fragment into the local file associated with |sender|.
213 // (and also keeps track of when all frames have been completed). 203 void OnSerializedHtmlFragment(RenderFrameHost* sender,
214 void OnSerializedHtmlWithLocalLinksResponse(RenderFrameHost* sender, 204 const std::string& data);
215 const GURL& frame_url, 205
216 const std::string& data, 206 // Response to GetSerializedHtmlWithLocalLinksForFrame above that replaces
217 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);
218 235
219 // Look up SaveItem by save id from in progress map. 236 // Look up SaveItem by save id from in progress map.
220 SaveItem* LookupItemInProcessBySaveId(int32 save_id); 237 SaveItem* LookupItemInProcessBySaveId(int32 save_id);
221 238
222 // 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.
223 void PutInProgressItemToSavedMap(SaveItem* save_item); 240 void PutInProgressItemToSavedMap(SaveItem* save_item);
224 241
225 // Retrieves the URL to be saved from the WebContents. 242 // Retrieves the URL to be saved from the WebContents.
226 GURL GetUrlToBeSaved(); 243 GURL GetUrlToBeSaved();
227 244
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 297
281 // Returns extension for supported MIME types (for example, for "text/plain" 298 // Returns extension for supported MIME types (for example, for "text/plain"
282 // it returns "txt"). 299 // it returns "txt").
283 static const base::FilePath::CharType* ExtensionForMimeType( 300 static const base::FilePath::CharType* ExtensionForMimeType(
284 const std::string& contents_mime_type); 301 const std::string& contents_mime_type);
285 302
286 typedef std::queue<SaveItem*> SaveItemQueue; 303 typedef std::queue<SaveItem*> SaveItemQueue;
287 // A queue for items we are about to start saving. 304 // A queue for items we are about to start saving.
288 SaveItemQueue waiting_item_queue_; 305 SaveItemQueue waiting_item_queue_;
289 306
290 // Used to de-dupe urls that are being gathered into |waiting_item_queue_|. 307 // Used to
291 std::set<GURL> unique_urls_to_save_; 308 // 1) de-dupe urls that are being gathered into |waiting_item_queue_|
292 309 // 2) find a SaveItem which needs to be updated with frame_tree_node_id or
293 // Temporarily stores urls of savable frames, until we can process them. 310 // referrer.
294 std::vector<GURL> frame_urls_to_save_; 311 std::map<GURL, SaveItem*> url_to_save_item_;
295 312
296 // 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.
297 int number_of_frames_pending_response_; 314 int number_of_frames_pending_response_;
298 315
299 typedef base::hash_map<int32, SaveItem*> SavedItemMap; 316 typedef base::hash_map<int32, SaveItem*> SavedItemMap;
300 // 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.
301 SavedItemMap saved_success_items_; 318 SavedItemMap saved_success_items_;
302 319
303 // Non-owning pointer for handling file writing on the file thread. 320 // Non-owning pointer for handling file writing on the file thread.
304 SaveFileManager* file_manager_; 321 SaveFileManager* file_manager_;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 friend class SavePackageTest; 383 friend class SavePackageTest;
367 FRIEND_TEST_ALL_PREFIXES(SavePackageTest, TestSuggestedSaveNames); 384 FRIEND_TEST_ALL_PREFIXES(SavePackageTest, TestSuggestedSaveNames);
368 FRIEND_TEST_ALL_PREFIXES(SavePackageTest, TestLongSafePureFilename); 385 FRIEND_TEST_ALL_PREFIXES(SavePackageTest, TestLongSafePureFilename);
369 386
370 DISALLOW_COPY_AND_ASSIGN(SavePackage); 387 DISALLOW_COPY_AND_ASSIGN(SavePackage);
371 }; 388 };
372 389
373 } // namespace content 390 } // namespace content
374 391
375 #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