OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 #ifndef CONTENT_BROWSER_DOWNLOAD_SAVE_FILE_MANAGER_H_ | 58 #ifndef CONTENT_BROWSER_DOWNLOAD_SAVE_FILE_MANAGER_H_ |
59 #define CONTENT_BROWSER_DOWNLOAD_SAVE_FILE_MANAGER_H_ | 59 #define CONTENT_BROWSER_DOWNLOAD_SAVE_FILE_MANAGER_H_ |
60 #pragma once | 60 #pragma once |
61 | 61 |
62 #include <string> | 62 #include <string> |
63 | 63 |
64 #include "base/basictypes.h" | 64 #include "base/basictypes.h" |
65 #include "base/hash_tables.h" | 65 #include "base/hash_tables.h" |
66 #include "base/memory/ref_counted.h" | 66 #include "base/memory/ref_counted.h" |
67 #include "content/browser/download/save_types.h" | 67 #include "content/browser/download/save_types.h" |
| 68 #include "content/common/content_export.h" |
68 | 69 |
69 class FilePath; | 70 class FilePath; |
70 class GURL; | 71 class GURL; |
71 class SaveFile; | 72 class SaveFile; |
72 class SavePackage; | 73 class SavePackage; |
73 class ResourceDispatcherHost; | 74 class ResourceDispatcherHost; |
74 class Task; | 75 class Task; |
75 | 76 |
76 namespace content { | 77 namespace content { |
77 class ResourceContext; | 78 class ResourceContext; |
78 } | 79 } |
79 | 80 |
80 namespace net { | 81 namespace net { |
81 class IOBuffer; | 82 class IOBuffer; |
82 } | 83 } |
83 | 84 |
84 class SaveFileManager | 85 class SaveFileManager |
85 : public base::RefCountedThreadSafe<SaveFileManager> { | 86 : public base::RefCountedThreadSafe<SaveFileManager> { |
86 public: | 87 public: |
87 explicit SaveFileManager(ResourceDispatcherHost* rdh); | 88 explicit SaveFileManager(ResourceDispatcherHost* rdh); |
88 | 89 |
89 // Lifetime management. | 90 // Lifetime management. |
90 void Shutdown(); | 91 CONTENT_EXPORT void Shutdown(); |
91 | 92 |
92 // Called on the IO thread. This generates unique IDs for | 93 // Called on the IO thread. This generates unique IDs for |
93 // SaveFileResourceHandler objects (there's one per file in a SavePackage). | 94 // SaveFileResourceHandler objects (there's one per file in a SavePackage). |
94 // Note that this is different from the SavePackage's id. | 95 // Note that this is different from the SavePackage's id. |
95 int GetNextId(); | 96 int GetNextId(); |
96 | 97 |
97 // Save the specified URL. Called on the UI thread and forwarded to the | 98 // Save the specified URL. Called on the UI thread and forwarded to the |
98 // ResourceDispatcherHost on the IO thread. | 99 // ResourceDispatcherHost on the IO thread. |
99 void SaveURL(const GURL& url, | 100 void SaveURL(const GURL& url, |
100 const GURL& referrer, | 101 const GURL& referrer, |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 // hashmap since it is possible to save same URL in different tab at | 243 // hashmap since it is possible to save same URL in different tab at |
243 // same time. | 244 // same time. |
244 typedef base::hash_map<std::string, SavePackage*> StartingRequestsMap; | 245 typedef base::hash_map<std::string, SavePackage*> StartingRequestsMap; |
245 typedef base::hash_map<int, StartingRequestsMap> TabToStartingRequestsMap; | 246 typedef base::hash_map<int, StartingRequestsMap> TabToStartingRequestsMap; |
246 TabToStartingRequestsMap tab_starting_requests_; | 247 TabToStartingRequestsMap tab_starting_requests_; |
247 | 248 |
248 DISALLOW_COPY_AND_ASSIGN(SaveFileManager); | 249 DISALLOW_COPY_AND_ASSIGN(SaveFileManager); |
249 }; | 250 }; |
250 | 251 |
251 #endif // CONTENT_BROWSER_DOWNLOAD_SAVE_FILE_MANAGER_H_ | 252 #endif // CONTENT_BROWSER_DOWNLOAD_SAVE_FILE_MANAGER_H_ |
OLD | NEW |