| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_TARGET_DETERMINER_H_ | 5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_TARGET_DETERMINER_H_ |
| 6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_TARGET_DETERMINER_H_ | 6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_TARGET_DETERMINER_H_ |
| 7 | 7 |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 // |callback| will be scheduled asynchronously on the UI thread after download | 63 // |callback| will be scheduled asynchronously on the UI thread after download |
| 64 // determination is complete or after |download| is destroyed. | 64 // determination is complete or after |download| is destroyed. |
| 65 // | 65 // |
| 66 // Start() should be called on the UI thread. | 66 // Start() should be called on the UI thread. |
| 67 static void Start(content::DownloadItem* download, | 67 static void Start(content::DownloadItem* download, |
| 68 DownloadPrefs* download_prefs, | 68 DownloadPrefs* download_prefs, |
| 69 const base::FilePath& last_selected_directory, | 69 const base::FilePath& last_selected_directory, |
| 70 DownloadTargetDeterminerDelegate* delegate, | 70 DownloadTargetDeterminerDelegate* delegate, |
| 71 const content::DownloadTargetCallback& callback); | 71 const content::DownloadTargetCallback& callback); |
| 72 | 72 |
| 73 // Returns a .crdownload intermediate path for the |suggested_path|. |
| 74 static base::FilePath GetCrDownloadPath(const base::FilePath& suggested_path); |
| 75 |
| 73 private: | 76 private: |
| 74 // The main workflow is controlled via a set of state transitions. Each state | 77 // The main workflow is controlled via a set of state transitions. Each state |
| 75 // has an associated handler. The handler for STATE_FOO is DoFoo. Each handler | 78 // has an associated handler. The handler for STATE_FOO is DoFoo. Each handler |
| 76 // performs work, determines the next state to transition to and returns a | 79 // performs work, determines the next state to transition to and returns a |
| 77 // Result indicating how the workflow should proceed. The loop ends when a | 80 // Result indicating how the workflow should proceed. The loop ends when a |
| 78 // handler returns COMPLETE. | 81 // handler returns COMPLETE. |
| 79 enum State { | 82 enum State { |
| 80 STATE_GENERATE_TARGET_PATH, | 83 STATE_GENERATE_TARGET_PATH, |
| 81 STATE_NOTIFY_EXTENSIONS, | 84 STATE_NOTIFY_EXTENSIONS, |
| 82 STATE_RESERVE_VIRTUAL_PATH, | 85 STATE_RESERVE_VIRTUAL_PATH, |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 base::FilePath last_selected_directory_; | 247 base::FilePath last_selected_directory_; |
| 245 content::DownloadTargetCallback completion_callback_; | 248 content::DownloadTargetCallback completion_callback_; |
| 246 CancelableRequestConsumer history_consumer_; | 249 CancelableRequestConsumer history_consumer_; |
| 247 | 250 |
| 248 base::WeakPtrFactory<DownloadTargetDeterminer> weak_ptr_factory_; | 251 base::WeakPtrFactory<DownloadTargetDeterminer> weak_ptr_factory_; |
| 249 | 252 |
| 250 DISALLOW_COPY_AND_ASSIGN(DownloadTargetDeterminer); | 253 DISALLOW_COPY_AND_ASSIGN(DownloadTargetDeterminer); |
| 251 }; | 254 }; |
| 252 | 255 |
| 253 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_TARGET_DETERMINER_H_ | 256 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_TARGET_DETERMINER_H_ |
| OLD | NEW |