| OLD | NEW |
| 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_DRAG_DOWNLOAD_FILE_H_ | 5 #ifndef CONTENT_BROWSER_DOWNLOAD_DRAG_DOWNLOAD_FILE_H_ |
| 6 #define CONTENT_BROWSER_DOWNLOAD_DRAG_DOWNLOAD_FILE_H_ | 6 #define CONTENT_BROWSER_DOWNLOAD_DRAG_DOWNLOAD_FILE_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/memory/linked_ptr.h" | 10 #include "base/memory/linked_ptr.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 // On Windows, we need to download into a temporary file. Two threads are | 34 // On Windows, we need to download into a temporary file. Two threads are |
| 35 // involved: background drag-and-drop thread and UI thread. | 35 // involved: background drag-and-drop thread and UI thread. |
| 36 // The first parameter file_name_or_path should contain file name while the | 36 // The first parameter file_name_or_path should contain file name while the |
| 37 // second parameter file_stream should be NULL. | 37 // second parameter file_stream should be NULL. |
| 38 // | 38 // |
| 39 // On MacOSX, we need to download into a file stream that has already been | 39 // On MacOSX, we need to download into a file stream that has already been |
| 40 // created. Only UI thread is involved. | 40 // created. Only UI thread is involved. |
| 41 // The file path and file stream should be provided as the first two | 41 // The file path and file stream should be provided as the first two |
| 42 // parameters. | 42 // parameters. |
| 43 DragDownloadFile(const FilePath& file_name_or_path, | 43 DragDownloadFile(const FilePath& file_name_or_path, |
| 44 linked_ptr<net::FileStream> file_stream, | 44 scoped_ptr<net::FileStream> file_stream, |
| 45 const GURL& url, | 45 const GURL& url, |
| 46 const content::Referrer& referrer, | 46 const content::Referrer& referrer, |
| 47 const std::string& referrer_encoding, | 47 const std::string& referrer_encoding, |
| 48 content::WebContents* web_contents); | 48 content::WebContents* web_contents); |
| 49 | 49 |
| 50 // DownloadFileProvider methods. | 50 // DownloadFileProvider methods. |
| 51 // Called on drag-and-drop thread (Windows). | 51 // Called on drag-and-drop thread (Windows). |
| 52 // Called on UI thread (MacOSX). | 52 // Called on UI thread (MacOSX). |
| 53 virtual bool Start(ui::DownloadFileObserver* observer) OVERRIDE; | 53 virtual bool Start(ui::DownloadFileObserver* observer) OVERRIDE; |
| 54 virtual void Stop() OVERRIDE; | 54 virtual void Stop() OVERRIDE; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 85 void AssertCurrentlyOnDragThread(); | 85 void AssertCurrentlyOnDragThread(); |
| 86 void AssertCurrentlyOnUIThread(); | 86 void AssertCurrentlyOnUIThread(); |
| 87 | 87 |
| 88 void RemoveObservers(); | 88 void RemoveObservers(); |
| 89 | 89 |
| 90 // Initialized on drag-and-drop thread. Accessed on either thread after that | 90 // Initialized on drag-and-drop thread. Accessed on either thread after that |
| 91 // (Windows). | 91 // (Windows). |
| 92 // Accessed on UI thread (MacOSX). | 92 // Accessed on UI thread (MacOSX). |
| 93 FilePath file_path_; | 93 FilePath file_path_; |
| 94 FilePath file_name_; | 94 FilePath file_name_; |
| 95 linked_ptr<net::FileStream> file_stream_; | 95 scoped_ptr<net::FileStream> file_stream_; |
| 96 GURL url_; | 96 GURL url_; |
| 97 content::Referrer referrer_; | 97 content::Referrer referrer_; |
| 98 std::string referrer_encoding_; | 98 std::string referrer_encoding_; |
| 99 content::WebContents* web_contents_; | 99 content::WebContents* web_contents_; |
| 100 MessageLoop* drag_message_loop_; | 100 MessageLoop* drag_message_loop_; |
| 101 FilePath temp_dir_path_; | 101 FilePath temp_dir_path_; |
| 102 | 102 |
| 103 // Accessed on drag-and-drop thread (Windows). | 103 // Accessed on drag-and-drop thread (Windows). |
| 104 // Accessed on UI thread (MacOSX). | 104 // Accessed on UI thread (MacOSX). |
| 105 bool is_started_; | 105 bool is_started_; |
| 106 bool is_successful_; | 106 bool is_successful_; |
| 107 scoped_refptr<ui::DownloadFileObserver> observer_; | 107 scoped_refptr<ui::DownloadFileObserver> observer_; |
| 108 | 108 |
| 109 // Accessed on drag-and-drop thread (Windows only). | 109 // Accessed on drag-and-drop thread (Windows only). |
| 110 #if defined(OS_WIN) | 110 #if defined(OS_WIN) |
| 111 bool is_running_nested_message_loop_; | 111 bool is_running_nested_message_loop_; |
| 112 #endif | 112 #endif |
| 113 | 113 |
| 114 // Access on UI thread. | 114 // Access on UI thread. |
| 115 content::DownloadManager* download_manager_; | 115 content::DownloadManager* download_manager_; |
| 116 bool download_manager_observer_added_; | 116 bool download_manager_observer_added_; |
| 117 content::DownloadItem* download_item_; | 117 content::DownloadItem* download_item_; |
| 118 | 118 |
| 119 DISALLOW_COPY_AND_ASSIGN(DragDownloadFile); | 119 DISALLOW_COPY_AND_ASSIGN(DragDownloadFile); |
| 120 }; | 120 }; |
| 121 | 121 |
| 122 #endif // CONTENT_BROWSER_DOWNLOAD_DRAG_DOWNLOAD_FILE_H_ | 122 #endif // CONTENT_BROWSER_DOWNLOAD_DRAG_DOWNLOAD_FILE_H_ |
| OLD | NEW |