| 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 #include "components/drive/file_system/search_operation.h" | 5 #include "components/drive/file_system/search_operation.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 // Short cut. If the resource entry is empty, we don't need to refresh | 138 // Short cut. If the resource entry is empty, we don't need to refresh |
| 139 // the resource metadata. | 139 // the resource metadata. |
| 140 callback.Run(FILE_ERROR_OK, next_url, std::move(result)); | 140 callback.Run(FILE_ERROR_OK, next_url, std::move(result)); |
| 141 return; | 141 return; |
| 142 } | 142 } |
| 143 | 143 |
| 144 // ResolveSearchResultOnBlockingPool() may add entries newly created on the | 144 // ResolveSearchResultOnBlockingPool() may add entries newly created on the |
| 145 // server to the local metadata. | 145 // server to the local metadata. |
| 146 // This may race with sync tasks so we should ask LoaderController here. | 146 // This may race with sync tasks so we should ask LoaderController here. |
| 147 std::vector<SearchResultInfo>* result_ptr = result.get(); | 147 std::vector<SearchResultInfo>* result_ptr = result.get(); |
| 148 loader_controller_->ScheduleRun(base::Bind( | 148 loader_controller_->ScheduleRun( |
| 149 base::IgnoreResult( | 149 base::Bind(base::IgnoreResult( |
| 150 &base::PostTaskAndReplyWithResult<FileError, FileError>), | 150 &base::PostTaskAndReplyWithResult<FileError, FileError>), |
| 151 blocking_task_runner_, | 151 base::RetainedRef(blocking_task_runner_), FROM_HERE, |
| 152 FROM_HERE, | 152 base::Bind(&ResolveSearchResultOnBlockingPool, metadata_, |
| 153 base::Bind(&ResolveSearchResultOnBlockingPool, | 153 base::Passed(&file_list), result_ptr), |
| 154 metadata_, | 154 base::Bind(&SearchOperation::SearchAfterResolveSearchResult, |
| 155 base::Passed(&file_list), | 155 weak_ptr_factory_.GetWeakPtr(), callback, next_url, |
| 156 result_ptr), | 156 base::Passed(&result)))); |
| 157 base::Bind(&SearchOperation::SearchAfterResolveSearchResult, | |
| 158 weak_ptr_factory_.GetWeakPtr(), | |
| 159 callback, | |
| 160 next_url, | |
| 161 base::Passed(&result)))); | |
| 162 } | 157 } |
| 163 | 158 |
| 164 void SearchOperation::SearchAfterResolveSearchResult( | 159 void SearchOperation::SearchAfterResolveSearchResult( |
| 165 const SearchCallback& callback, | 160 const SearchCallback& callback, |
| 166 const GURL& next_link, | 161 const GURL& next_link, |
| 167 scoped_ptr<std::vector<SearchResultInfo> > result, | 162 scoped_ptr<std::vector<SearchResultInfo> > result, |
| 168 FileError error) { | 163 FileError error) { |
| 169 DCHECK(thread_checker_.CalledOnValidThread()); | 164 DCHECK(thread_checker_.CalledOnValidThread()); |
| 170 DCHECK(!callback.is_null()); | 165 DCHECK(!callback.is_null()); |
| 171 DCHECK(result); | 166 DCHECK(result); |
| 172 | 167 |
| 173 if (error != FILE_ERROR_OK) { | 168 if (error != FILE_ERROR_OK) { |
| 174 callback.Run(error, GURL(), scoped_ptr<std::vector<SearchResultInfo> >()); | 169 callback.Run(error, GURL(), scoped_ptr<std::vector<SearchResultInfo> >()); |
| 175 return; | 170 return; |
| 176 } | 171 } |
| 177 | 172 |
| 178 callback.Run(error, next_link, std::move(result)); | 173 callback.Run(error, next_link, std::move(result)); |
| 179 } | 174 } |
| 180 | 175 |
| 181 } // namespace file_system | 176 } // namespace file_system |
| 182 } // namespace drive | 177 } // namespace drive |
| OLD | NEW |