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

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

Issue 2890853002: Downloads: replace BrowserThread::FILE with task scheduler. (Closed)
Patch Set: Revert ScopedCOMInitializer invocations. Created 3 years, 5 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 // Objects that handle file operations for saving files, on the file thread. 5 // Objects that handle file operations for saving files, on the file thread.
6 // 6 //
7 // The SaveFileManager owns a set of SaveFile objects, each of which connects 7 // The SaveFileManager owns a set of SaveFile objects, each of which connects
8 // with a SaveItem object which belongs to one SavePackage and runs on the file 8 // with a SaveItem object which belongs to one SavePackage and runs on the file
9 // thread for saving data in order to avoid disk activity on either network IO 9 // thread for saving data in order to avoid disk activity on either network IO
10 // thread or the UI thread. It coordinates the notifications from the network 10 // thread or the UI thread. It coordinates the notifications from the network
11 // and UI. 11 // and UI.
12 // 12 //
13 // The SaveFileManager itself is a singleton object owned by the 13 // The SaveFileManager itself is a singleton object owned by the
14 // ResourceDispatcherHostImpl. 14 // ResourceDispatcherHostImpl.
15 // 15 //
16 // The data sent to SaveFileManager have 2 sources, one is from 16 // The data sent to SaveFileManager have 2 sources, one is from
17 // ResourceDispatcherHostImpl, run in network IO thread, the all sub-resources 17 // ResourceDispatcherHostImpl, run in network IO thread, the all sub-resources
18 // and save-only-HTML pages will be got from network IO. The second is from 18 // and save-only-HTML pages will be got from network IO. The second is from
19 // render process, those html pages which are serialized from DOM will be 19 // render process, those html pages which are serialized from DOM will be
20 // composed in render process and encoded to its original encoding, then sent 20 // composed in render process and encoded to its original encoding, then sent
21 // to UI loop in browser process, then UI loop will dispatch the data to 21 // to UI loop in browser process, then UI loop will dispatch the data to
22 // SaveFileManager on the file thread. SaveFileManager will directly 22 // SaveFileManager on the file thread. SaveFileManager will directly
23 // call SaveFile's method to persist data. 23 // call SaveFile's method to persist data.
24 // 24 //
25 // A typical saving job operation involves multiple threads: 25 // A typical saving job operation involves multiple threads and sequences:
26 // 26 //
27 // Updating an in progress save file 27 // Updating an in progress save file
28 // io_thread 28 // io_thread
29 // |----> data from net ---->| 29 // |----> data from net ---->|
30 // | 30 // |
31 // | 31 // |
32 // |----> data from ---->| | 32 // |----> data from ---->| |
33 // | render process | | 33 // | render process | |
34 // ui_thread | | 34 // ui_thread | |
35 // file_thread (writes to disk) 35 // download_task_runner (writes to disk)
36 // |----> stats ---->| 36 // |----> stats ---->|
37 // ui_thread (feedback for user) 37 // ui_thread (feedback for user)
38 // 38 //
39 // 39 //
40 // Cancel operations perform the inverse order when triggered by a user action: 40 // Cancel operations perform the inverse order when triggered by a user action:
41 // ui_thread (user click) 41 // ui_thread (user click)
42 // |----> cancel command ---->| 42 // |----> cancel command ---->|
43 // | | file_thread (close file) 43 // | | download_task_runner (close file)
44 // | |---------------------> cancel command ---->| 44 // | |---------------------> cancel command ---->|
45 // | io_thread (stops net IO 45 // | io_thread (stops net IO
46 // ui_thread (user close contents) for saving) 46 // ui_thread (user close contents) for saving)
47 // |----> cancel command ---->| 47 // |----> cancel command ---->|
48 // Render process(stop serializing DOM and sending 48 // Render process(stop serializing DOM and sending
49 // data) 49 // data)
50 // 50 //
51 // 51 //
52 // The SaveFileManager tracks saving requests, mapping from a save item id to 52 // The SaveFileManager tracks saving requests, mapping from a save item id to
53 // the SavePackage for the contents where the saving job was initiated. In the 53 // the SavePackage for the contents where the saving job was initiated. In the
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 // Tracks which SavePackage to send data to, called only on UI thread. 216 // Tracks which SavePackage to send data to, called only on UI thread.
217 // SavePackageMap maps save item ids to their SavePackage. 217 // SavePackageMap maps save item ids to their SavePackage.
218 std::unordered_map<SaveItemId, SavePackage*, SaveItemId::Hasher> packages_; 218 std::unordered_map<SaveItemId, SavePackage*, SaveItemId::Hasher> packages_;
219 219
220 DISALLOW_COPY_AND_ASSIGN(SaveFileManager); 220 DISALLOW_COPY_AND_ASSIGN(SaveFileManager);
221 }; 221 };
222 222
223 } // namespace content 223 } // namespace content
224 224
225 #endif // CONTENT_BROWSER_DOWNLOAD_SAVE_FILE_MANAGER_H_ 225 #endif // CONTENT_BROWSER_DOWNLOAD_SAVE_FILE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698