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 27 matching lines...) Expand all Loading... | |
38 | 38 |
39 class DownloadOperation { | 39 class DownloadOperation { |
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 ~DownloadOperation(); | 46 ~DownloadOperation(); |
47 | 47 |
48 // Ensures that the file content is locally downloaded. | 48 // Ensures that the file content is locally downloaded. |
satorux1
2013/05/30 01:14:35
the file content, specified by |resource_id|,
hashimoto
2013/05/30 01:47:25
Done.
| |
49 // For hosted documents, this method may create a JSON file representing the | 49 // For hosted documents, this method may create a JSON file representing the |
50 // file. | 50 // file. |
51 // For regular files, if the locally cached file is found, returns it. | 51 // For regular files, if the locally cached file is found, returns it. |
52 // If not found, start to download the file from the server. | 52 // If not found, start to download the file from the server. |
53 // When a JSON file is created, the cache file is found or downloading is | 53 // When a JSON file is created, the cache file is found or downloading is |
54 // being started, |initialized_callback| is called with |local_file| | 54 // being started, |initialized_callback| is called with |local_file| |
55 // for JSON file or the cache file, or with |cancel_download_closure| for | 55 // for JSON file or the cache file, or with |cancel_download_closure| for |
56 // downloading. | 56 // downloading. |
57 // During the downloading |get_content_callback| will be called periodically | 57 // During the downloading |get_content_callback| will be called periodically |
58 // with the downloaded content. | 58 // with the downloaded content. |
59 // Upon completion or an error is found, |completion_callback| will be | 59 // Upon completion or an error is found, |completion_callback| will be |
60 // called. | 60 // called. |
61 // |initialized_callback| and |get_content_callback| can be null if not | 61 // |initialized_callback| and |get_content_callback| can be null if not |
62 // needed. | 62 // needed. |
63 // |completion_callback| must not be null. | 63 // |completion_callback| must not be null. |
64 void EnsureFileDownloaded( | 64 void EnsureFileDownloadedByResourceId( |
satorux1
2013/05/30 01:14:35
Could you add a test for this function? you might
hashimoto
2013/05/30 01:47:25
This method is tested by FileSystemTest.GetFileByR
| |
65 const std::string& resource_id, | |
66 const ClientContext& context, | |
67 const GetFileContentInitializedCallback& initialized_callback, | |
68 const google_apis::GetContentCallback& get_content_callback, | |
69 const GetFileCallback& completion_callback); | |
70 | |
71 // Does the same thing as EnsureFileDownloadedByResourceId for the file | |
72 // specified with |file_path|. | |
73 void EnsureFileDownloadedByPath( | |
65 const base::FilePath& file_path, | 74 const base::FilePath& file_path, |
66 const ClientContext& context, | 75 const ClientContext& context, |
67 const GetFileContentInitializedCallback& initialized_callback, | 76 const GetFileContentInitializedCallback& initialized_callback, |
68 const google_apis::GetContentCallback& get_content_callback, | 77 const google_apis::GetContentCallback& get_content_callback, |
69 const GetFileCallback& completion_callback); | 78 const GetFileCallback& completion_callback); |
70 | 79 |
71 private: | 80 private: |
72 // Thin wrapper of Callbacks for EnsureFileDownloaded. | 81 // Thin wrapper of Callbacks for EnsureFileDownloaded. |
73 class DownloadCallback; | 82 class DownloadCallback; |
74 | 83 |
75 // Parameters for JobScheduler::DownloadFile. | 84 // Parameters for JobScheduler::DownloadFile. |
76 struct DownloadParams; | 85 struct DownloadParams; |
77 | 86 |
78 // Part of EnsureFileDownloaded(). Called upon the completion of precondition | 87 // Part of EnsureFileDownloaded(). Called upon the completion of precondition |
79 // check. | 88 // check. |
80 void EnsureFileDownloadedAfterCheckPreCondition( | 89 void EnsureFileDownloadedAfterCheckPreCondition( |
81 const base::FilePath& file_path, | |
82 const ClientContext& context, | 90 const ClientContext& context, |
83 const DownloadCallback& callback, | 91 const DownloadCallback& callback, |
84 scoped_ptr<ResourceEntry> entry, | 92 scoped_ptr<ResourceEntry> entry, |
85 base::FilePath* cache_file_path, | 93 base::FilePath* cache_file_path, |
86 FileError error); | 94 FileError error); |
87 | 95 |
88 // Part of EnsureFileDownloaded(). Called upon the completion of fetching | 96 // Part of EnsureFileDownloaded(). Called upon the completion of fetching |
89 // ResourceEntry from the server. | 97 // ResourceEntry from the server. |
90 void EnsureFileDownloadedAfterGetResourceEntry( | 98 void EnsureFileDownloadedAfterGetResourceEntry( |
91 const ClientContext& context, | 99 const ClientContext& context, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
129 // Note: This should remain the last member so it'll be destroyed and | 137 // Note: This should remain the last member so it'll be destroyed and |
130 // invalidate its weak pointers before any other members are destroyed. | 138 // invalidate its weak pointers before any other members are destroyed. |
131 base::WeakPtrFactory<DownloadOperation> weak_ptr_factory_; | 139 base::WeakPtrFactory<DownloadOperation> weak_ptr_factory_; |
132 DISALLOW_COPY_AND_ASSIGN(DownloadOperation); | 140 DISALLOW_COPY_AND_ASSIGN(DownloadOperation); |
133 }; | 141 }; |
134 | 142 |
135 } // namespace file_system | 143 } // namespace file_system |
136 } // namespace drive | 144 } // namespace drive |
137 | 145 |
138 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_DOWNLOAD_OPERATION_H_ | 146 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_DOWNLOAD_OPERATION_H_ |
OLD | NEW |