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_CHROMEOS_DRIVE_FILE_SYSTEM_DOWNLOAD_OPERATION_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_DOWNLOAD_OPERATION_H_ |
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_DOWNLOAD_OPERATION_H_ | 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_DOWNLOAD_OPERATION_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "chrome/browser/chromeos/drive/file_errors.h" | 10 #include "chrome/browser/chromeos/drive/file_errors.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 public: | 40 public: |
41 DownloadOperation(base::SequencedTaskRunner* blocking_task_runner, | 41 DownloadOperation(base::SequencedTaskRunner* blocking_task_runner, |
42 OperationObserver* observer, | 42 OperationObserver* observer, |
43 JobScheduler* scheduler, | 43 JobScheduler* scheduler, |
44 internal::ResourceMetadata* metadata, | 44 internal::ResourceMetadata* metadata, |
45 internal::FileCache* cache, | 45 internal::FileCache* cache, |
46 const base::FilePath& temporary_file_directory); | 46 const base::FilePath& temporary_file_directory); |
47 ~DownloadOperation(); | 47 ~DownloadOperation(); |
48 | 48 |
49 // Ensures that the file content specified by |local_id| is locally | 49 // Ensures that the file content specified by |local_id| is locally |
50 // downloaded. | 50 // downloaded and returns a closure to cancel the task. |
51 // For hosted documents, this method may create a JSON file representing the | 51 // For hosted documents, this method may create a JSON file representing the |
52 // file. | 52 // file. |
53 // For regular files, if the locally cached file is found, returns it. | 53 // For regular files, if the locally cached file is found, returns it. |
54 // If not found, start to download the file from the server. | 54 // If not found, start to download the file from the server. |
55 // When a JSON file is created, the cache file is found or downloading is | 55 // When a JSON file is created, the cache file is found or downloading is |
56 // being started, |initialized_callback| is called with |local_file| | 56 // being started, |initialized_callback| is called with |local_file| |
57 // for JSON file or the cache file, or with |cancel_download_closure| for | 57 // for JSON file or the cache file, or with |cancel_download_closure| for |
58 // downloading. | 58 // downloading. |
59 // During the downloading |get_content_callback| will be called periodically | 59 // During the downloading |get_content_callback| will be called periodically |
60 // with the downloaded content. | 60 // with the downloaded content. |
61 // Upon completion or an error is found, |completion_callback| will be called. | 61 // Upon completion or an error is found, |completion_callback| will be called. |
62 // |initialized_callback| and |get_content_callback| can be null if not | 62 // |initialized_callback| and |get_content_callback| can be null if not |
63 // needed. | 63 // needed. |
64 // |completion_callback| must not be null. | 64 // |completion_callback| must not be null. |
65 void EnsureFileDownloadedByLocalId( | 65 base::Closure EnsureFileDownloadedByLocalId( |
66 const std::string& local_id, | 66 const std::string& local_id, |
67 const ClientContext& context, | 67 const ClientContext& context, |
68 const GetFileContentInitializedCallback& initialized_callback, | 68 const GetFileContentInitializedCallback& initialized_callback, |
69 const google_apis::GetContentCallback& get_content_callback, | 69 const google_apis::GetContentCallback& get_content_callback, |
70 const GetFileCallback& completion_callback); | 70 const GetFileCallback& completion_callback); |
71 | 71 |
72 // Does the same thing as EnsureFileDownloadedByLocalId for the file | 72 // Does the same thing as EnsureFileDownloadedByLocalId for the file |
73 // specified by |file_path|. | 73 // specified by |file_path|. |
74 void EnsureFileDownloadedByPath( | 74 base::Closure EnsureFileDownloadedByPath( |
75 const base::FilePath& file_path, | 75 const base::FilePath& file_path, |
76 const ClientContext& context, | 76 const ClientContext& context, |
77 const GetFileContentInitializedCallback& initialized_callback, | 77 const GetFileContentInitializedCallback& initialized_callback, |
78 const google_apis::GetContentCallback& get_content_callback, | 78 const google_apis::GetContentCallback& get_content_callback, |
79 const GetFileCallback& completion_callback); | 79 const GetFileCallback& completion_callback); |
80 | 80 |
81 private: | 81 private: |
82 // Parameters for EnsureFileDownloaded. | 82 // Parameters for EnsureFileDownloaded. |
83 class DownloadParams; | 83 class DownloadParams; |
84 | 84 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 // Note: This should remain the last member so it'll be destroyed and | 128 // Note: This should remain the last member so it'll be destroyed and |
129 // invalidate its weak pointers before any other members are destroyed. | 129 // invalidate its weak pointers before any other members are destroyed. |
130 base::WeakPtrFactory<DownloadOperation> weak_ptr_factory_; | 130 base::WeakPtrFactory<DownloadOperation> weak_ptr_factory_; |
131 DISALLOW_COPY_AND_ASSIGN(DownloadOperation); | 131 DISALLOW_COPY_AND_ASSIGN(DownloadOperation); |
132 }; | 132 }; |
133 | 133 |
134 } // namespace file_system | 134 } // namespace file_system |
135 } // namespace drive | 135 } // namespace drive |
136 | 136 |
137 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_DOWNLOAD_OPERATION_H_ | 137 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_DOWNLOAD_OPERATION_H_ |
OLD | NEW |