Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1656)

Side by Side Diff: components/drive/chromeos/file_system/search_operation.cc

Issue 2842493004: Add OnceCallback support to PostTaskAndReplyWithResult (Closed)
Patch Set: s/can not/cannot/ Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/drive/chromeos/directory_loader.cc ('k') | components/drive/drive_api_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/chromeos/file_system/search_operation.h" 5 #include "components/drive/chromeos/file_system/search_operation.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
11 #include <utility> 11 #include <utility>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/bind.h" 14 #include "base/bind.h"
15 #include "base/bind_helpers.h" 15 #include "base/bind_helpers.h"
16 #include "base/callback.h" 16 #include "base/callback.h"
17 #include "base/task_runner_util.h"
18 #include "components/drive/chromeos/change_list_loader.h" 17 #include "components/drive/chromeos/change_list_loader.h"
19 #include "components/drive/chromeos/resource_metadata.h" 18 #include "components/drive/chromeos/resource_metadata.h"
20 #include "components/drive/drive_api_util.h" 19 #include "components/drive/drive_api_util.h"
21 #include "components/drive/file_system_core_util.h" 20 #include "components/drive/file_system_core_util.h"
22 #include "components/drive/job_scheduler.h" 21 #include "components/drive/job_scheduler.h"
23 #include "components/drive/resource_entry_conversion.h" 22 #include "components/drive/resource_entry_conversion.h"
24 #include "google_apis/drive/drive_api_parser.h" 23 #include "google_apis/drive/drive_api_parser.h"
25 #include "url/gurl.h" 24 #include "url/gurl.h"
26 25
27 namespace drive { 26 namespace drive {
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 // the resource metadata. 142 // the resource metadata.
144 callback.Run(FILE_ERROR_OK, next_url, std::move(result)); 143 callback.Run(FILE_ERROR_OK, next_url, std::move(result));
145 return; 144 return;
146 } 145 }
147 146
148 // ResolveSearchResultOnBlockingPool() may add entries newly created on the 147 // ResolveSearchResultOnBlockingPool() may add entries newly created on the
149 // server to the local metadata. 148 // server to the local metadata.
150 // This may race with sync tasks so we should ask LoaderController here. 149 // This may race with sync tasks so we should ask LoaderController here.
151 std::vector<SearchResultInfo>* result_ptr = result.get(); 150 std::vector<SearchResultInfo>* result_ptr = result.get();
152 loader_controller_->ScheduleRun( 151 loader_controller_->ScheduleRun(
153 base::Bind(base::IgnoreResult( 152 base::Bind(&drive::util::RunAsyncTask,
154 &base::PostTaskAndReplyWithResult<FileError, FileError>),
155 base::RetainedRef(blocking_task_runner_), FROM_HERE, 153 base::RetainedRef(blocking_task_runner_), FROM_HERE,
156 base::Bind(&ResolveSearchResultOnBlockingPool, metadata_, 154 base::Bind(&ResolveSearchResultOnBlockingPool, metadata_,
157 base::Passed(&file_list), result_ptr), 155 base::Passed(&file_list), result_ptr),
158 base::Bind(&SearchOperation::SearchAfterResolveSearchResult, 156 base::Bind(&SearchOperation::SearchAfterResolveSearchResult,
159 weak_ptr_factory_.GetWeakPtr(), callback, next_url, 157 weak_ptr_factory_.GetWeakPtr(), callback, next_url,
160 base::Passed(&result)))); 158 base::Passed(&result))));
161 } 159 }
162 160
163 void SearchOperation::SearchAfterResolveSearchResult( 161 void SearchOperation::SearchAfterResolveSearchResult(
164 const SearchCallback& callback, 162 const SearchCallback& callback,
165 const GURL& next_link, 163 const GURL& next_link,
166 std::unique_ptr<std::vector<SearchResultInfo>> result, 164 std::unique_ptr<std::vector<SearchResultInfo>> result,
167 FileError error) { 165 FileError error) {
168 DCHECK(thread_checker_.CalledOnValidThread()); 166 DCHECK(thread_checker_.CalledOnValidThread());
169 DCHECK(!callback.is_null()); 167 DCHECK(!callback.is_null());
170 DCHECK(result); 168 DCHECK(result);
171 169
172 if (error != FILE_ERROR_OK) { 170 if (error != FILE_ERROR_OK) {
173 callback.Run(error, GURL(), 171 callback.Run(error, GURL(),
174 std::unique_ptr<std::vector<SearchResultInfo>>()); 172 std::unique_ptr<std::vector<SearchResultInfo>>());
175 return; 173 return;
176 } 174 }
177 175
178 callback.Run(error, next_link, std::move(result)); 176 callback.Run(error, next_link, std::move(result));
179 } 177 }
180 178
181 } // namespace file_system 179 } // namespace file_system
182 } // namespace drive 180 } // namespace drive
OLDNEW
« no previous file with comments | « components/drive/chromeos/directory_loader.cc ('k') | components/drive/drive_api_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698