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

Side by Side Diff: chrome/browser/download/download_path_reservation_tracker.h

Issue 12163003: Add FilePath to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 | Annotate | Revision Log
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 CHROME_BROWSER_DOWNLOAD_DOWNLOAD_PATH_RESERVATION_TRACKER_H_ 5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_PATH_RESERVATION_TRACKER_H_
6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_PATH_RESERVATION_TRACKER_H_ 6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_PATH_RESERVATION_TRACKER_H_
7 7
8 #include "base/callback_forward.h" 8 #include "base/callback_forward.h"
9 9
10 // DownloadPathReservationTracker: Track download paths that are in use by 10 // DownloadPathReservationTracker: Track download paths that are in use by
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 // enforce uniqueness. It is only used for uniquifying new reservations. 56 // enforce uniqueness. It is only used for uniquifying new reservations.
57 // 57 //
58 // Once |completion_callback| is invoked, it is the caller's responsibility to 58 // Once |completion_callback| is invoked, it is the caller's responsibility to
59 // handle cases where the target path could not be verified and set the target 59 // handle cases where the target path could not be verified and set the target
60 // path of the |download_item| appropriately. 60 // path of the |download_item| appropriately.
61 // 61 //
62 // Note: The current implementation doesn't look at symlinks/mount points. E.g.: 62 // Note: The current implementation doesn't look at symlinks/mount points. E.g.:
63 // It considers 'foo/bar/x.pdf' and 'foo/baz/x.pdf' to be two different paths, 63 // It considers 'foo/bar/x.pdf' and 'foo/baz/x.pdf' to be two different paths,
64 // even though 'bar' might be a symlink to 'baz'. 64 // even though 'bar' might be a symlink to 'baz'.
65 65
66 namespace base {
67 class FilePath;
68 }
69
66 namespace content { 70 namespace content {
67 class DownloadItem; 71 class DownloadItem;
68 } 72 }
69 73
70 class FilePath;
71
72 // Issues and tracks download paths that are in use by the download system. When 74 // Issues and tracks download paths that are in use by the download system. When
73 // a target path is set for a download, this object tracks the path and the 75 // a target path is set for a download, this object tracks the path and the
74 // associated download item so that subsequent downloads can avoid using the 76 // associated download item so that subsequent downloads can avoid using the
75 // same path. 77 // same path.
76 class DownloadPathReservationTracker { 78 class DownloadPathReservationTracker {
77 public: 79 public:
78 // Callback used with |GetReservedPath|. |target_path| specifies the target 80 // Callback used with |GetReservedPath|. |target_path| specifies the target
79 // path for the download. |target_path_verified| is true if all of the 81 // path for the download. |target_path_verified| is true if all of the
80 // following is true: 82 // following is true:
81 // - |requested_target_path| (passed into GetReservedPath()) was writeable. 83 // - |requested_target_path| (passed into GetReservedPath()) was writeable.
82 // - |target_path| was verified as being unique if uniqueness was 84 // - |target_path| was verified as being unique if uniqueness was
83 // required. 85 // required.
84 // 86 //
85 // If |requested_target_path| was not writeable, then the parent directory of 87 // If |requested_target_path| was not writeable, then the parent directory of
86 // |target_path| may be different from that of |requested_target_path|. 88 // |target_path| may be different from that of |requested_target_path|.
87 typedef base::Callback<void(const FilePath& target_path, 89 typedef base::Callback<void(const base::FilePath& target_path,
88 bool target_path_verified)> ReservedPathCallback; 90 bool target_path_verified)> ReservedPathCallback;
89 91
90 // The largest index for the uniquification suffix that we will try while 92 // The largest index for the uniquification suffix that we will try while
91 // attempting to come up with a unique path. 93 // attempting to come up with a unique path.
92 static const int kMaxUniqueFiles = 100; 94 static const int kMaxUniqueFiles = 100;
93 95
94 // Called on the UI thread to request a download path reservation. Begins 96 // Called on the UI thread to request a download path reservation. Begins
95 // observing |download_item| and initiates creating a reservation on the FILE 97 // observing |download_item| and initiates creating a reservation on the FILE
96 // thread. Will not modify any state of |download_item|. 98 // thread. Will not modify any state of |download_item|.
97 // 99 //
98 // |default_download_path| is the user's default download path. If this 100 // |default_download_path| is the user's default download path. If this
99 // directory does not exist and is the parent directory of 101 // directory does not exist and is the parent directory of
100 // |requested_target_path|, the directory will be created. 102 // |requested_target_path|, the directory will be created.
101 static void GetReservedPath(content::DownloadItem& download_item, 103 static void GetReservedPath(content::DownloadItem& download_item,
102 const FilePath& requested_target_path, 104 const base::FilePath& requested_target_path,
103 const FilePath& default_download_path, 105 const base::FilePath& default_download_path,
104 bool should_uniquify_path, 106 bool should_uniquify_path,
105 const ReservedPathCallback& callback); 107 const ReservedPathCallback& callback);
106 108
107 // Returns true if |path| is in use by an existing path reservation. Should 109 // Returns true if |path| is in use by an existing path reservation. Should
108 // only be called on the FILE thread. Currently only used by tests. 110 // only be called on the FILE thread. Currently only used by tests.
109 static bool IsPathInUseForTesting(const FilePath& path); 111 static bool IsPathInUseForTesting(const base::FilePath& path);
110 }; 112 };
111 113
112 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_PATH_RESERVATION_TRACKER_H_ 114 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_PATH_RESERVATION_TRACKER_H_
OLDNEW
« no previous file with comments | « chrome/browser/download/download_file_picker.h ('k') | chrome/browser/enumerate_modules_model_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698