| OLD | NEW |
| 1 // Copyright (c) 2011 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_UTIL_H_ | 5 #ifndef CONTENT_BROWSER_DOWNLOAD_DRAG_DOWNLOAD_UTIL_H_ |
| 6 #define CONTENT_BROWSER_DOWNLOAD_DRAG_DOWNLOAD_UTIL_H_ | 6 #define CONTENT_BROWSER_DOWNLOAD_DRAG_DOWNLOAD_UTIL_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/string16.h" | 11 #include "base/string16.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 31 // For example, we can have | 31 // For example, we can have |
| 32 // text/plain:example.txt:http://example.com/example.txt | 32 // text/plain:example.txt:http://example.com/example.txt |
| 33 CONTENT_EXPORT bool ParseDownloadMetadata(const string16& metadata, | 33 CONTENT_EXPORT bool ParseDownloadMetadata(const string16& metadata, |
| 34 string16* mime_type, | 34 string16* mime_type, |
| 35 FilePath* file_name, | 35 FilePath* file_name, |
| 36 GURL* url); | 36 GURL* url); |
| 37 | 37 |
| 38 // Create a new file at the specified path. If the file already exists, try to | 38 // Create a new file at the specified path. If the file already exists, try to |
| 39 // insert the sequential unifier to produce a new file, like foo-01.txt. | 39 // insert the sequential unifier to produce a new file, like foo-01.txt. |
| 40 // Return a FileStream if successful. | 40 // Return a FileStream if successful. |
| 41 CONTENT_EXPORT net::FileStream* CreateFileStreamForDrop(FilePath* file_path); | 41 // |net_log| is a NetLog for the stream. |
| 42 CONTENT_EXPORT net::FileStream* CreateFileStreamForDrop( |
| 43 FilePath* file_path, net::NetLog* net_log); |
| 42 | 44 |
| 43 // Implementation of DownloadFileObserver to finalize the download process. | 45 // Implementation of DownloadFileObserver to finalize the download process. |
| 44 class CONTENT_EXPORT PromiseFileFinalizer : public ui::DownloadFileObserver { | 46 class CONTENT_EXPORT PromiseFileFinalizer : public ui::DownloadFileObserver { |
| 45 public: | 47 public: |
| 46 explicit PromiseFileFinalizer(DragDownloadFile* drag_file_downloader); | 48 explicit PromiseFileFinalizer(DragDownloadFile* drag_file_downloader); |
| 47 virtual ~PromiseFileFinalizer(); | 49 virtual ~PromiseFileFinalizer(); |
| 48 | 50 |
| 49 // DownloadFileObserver methods. | 51 // DownloadFileObserver methods. |
| 50 virtual void OnDownloadCompleted(const FilePath& file_path) OVERRIDE; | 52 virtual void OnDownloadCompleted(const FilePath& file_path) OVERRIDE; |
| 51 virtual void OnDownloadAborted() OVERRIDE; | 53 virtual void OnDownloadAborted() OVERRIDE; |
| 52 | 54 |
| 53 private: | 55 private: |
| 54 void Cleanup(); | 56 void Cleanup(); |
| 55 | 57 |
| 56 scoped_refptr<DragDownloadFile> drag_file_downloader_; | 58 scoped_refptr<DragDownloadFile> drag_file_downloader_; |
| 57 | 59 |
| 58 DISALLOW_COPY_AND_ASSIGN(PromiseFileFinalizer); | 60 DISALLOW_COPY_AND_ASSIGN(PromiseFileFinalizer); |
| 59 }; | 61 }; |
| 60 | 62 |
| 61 } // namespace drag_download_util | 63 } // namespace drag_download_util |
| 62 | 64 |
| 63 #endif // CONTENT_BROWSER_DOWNLOAD_DRAG_DOWNLOAD_UTIL_H_ | 65 #endif // CONTENT_BROWSER_DOWNLOAD_DRAG_DOWNLOAD_UTIL_H_ |
| OLD | NEW |