| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef UI_BASE_DRAGDROP_DOWNLOAD_FILE_INTERFACE_H_ | |
| 6 #define UI_BASE_DRAGDROP_DOWNLOAD_FILE_INTERFACE_H_ | |
| 7 | |
| 8 #include "build/build_config.h" | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/memory/ref_counted.h" | |
| 12 | |
| 13 #include "ui/base/ui_base_export.h" | |
| 14 | |
| 15 #if defined(OS_WIN) | |
| 16 #include <objidl.h> | |
| 17 #endif | |
| 18 | |
| 19 namespace base { | |
| 20 class FilePath; | |
| 21 } | |
| 22 | |
| 23 namespace ui { | |
| 24 | |
| 25 // TODO(benjhayden, anybody): Do these need to be RefCountedThreadSafe? | |
| 26 | |
| 27 // Defines the interface to observe the status of file download. | |
| 28 class UI_BASE_EXPORT DownloadFileObserver | |
| 29 : public base::RefCountedThreadSafe<DownloadFileObserver> { | |
| 30 public: | |
| 31 virtual void OnDownloadCompleted(const base::FilePath& file_path) = 0; | |
| 32 virtual void OnDownloadAborted() = 0; | |
| 33 | |
| 34 protected: | |
| 35 friend class base::RefCountedThreadSafe<DownloadFileObserver>; | |
| 36 virtual ~DownloadFileObserver() {} | |
| 37 }; | |
| 38 | |
| 39 // Defines the interface to control how a file is downloaded. | |
| 40 class UI_BASE_EXPORT DownloadFileProvider | |
| 41 : public base::RefCountedThreadSafe<DownloadFileProvider> { | |
| 42 public: | |
| 43 // Starts the download asynchronously and returns immediately. | |
| 44 virtual void Start(DownloadFileObserver* observer) = 0; | |
| 45 | |
| 46 // Returns true if the download succeeded and false otherwise. Waits until the | |
| 47 // download is completed/cancelled/interrupted before returning. | |
| 48 virtual bool Wait() = 0; | |
| 49 | |
| 50 // Cancels the download. | |
| 51 virtual void Stop() = 0; | |
| 52 | |
| 53 protected: | |
| 54 friend class base::RefCountedThreadSafe<DownloadFileProvider>; | |
| 55 virtual ~DownloadFileProvider() {} | |
| 56 }; | |
| 57 | |
| 58 } // namespace ui | |
| 59 | |
| 60 #endif // UI_BASE_DRAGDROP_DOWNLOAD_FILE_INTERFACE_H_ | |
| OLD | NEW |