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

Side by Side Diff: chrome/browser/sync_file_system/drive_backend/sync_task_manager.cc

Issue 2605433002: Remove base::ScopedPtrHashMap from chrome/browser/sync_file_system/drive_backend/ (Closed)
Patch Set: no crash Created 3 years, 11 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 | « chrome/browser/sync_file_system/drive_backend/sync_task_manager.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/sync_file_system/drive_backend/sync_task_manager.h" 5 #include "chrome/browser/sync_file_system/drive_backend/sync_task_manager.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 bool SyncTaskManager::IsRunningTask(int64_t token_id) const { 194 bool SyncTaskManager::IsRunningTask(int64_t token_id) const {
195 DCHECK(sequence_checker_.CalledOnValidSequence()); 195 DCHECK(sequence_checker_.CalledOnValidSequence());
196 196
197 // If the client is gone, all task should be aborted. 197 // If the client is gone, all task should be aborted.
198 if (!client_) 198 if (!client_)
199 return false; 199 return false;
200 200
201 if (token_id == SyncTaskToken::kForegroundTaskTokenID) 201 if (token_id == SyncTaskToken::kForegroundTaskTokenID)
202 return true; 202 return true;
203 203
204 return ContainsKey(running_background_tasks_, token_id); 204 return running_background_tasks_.find(token_id) !=
205 running_background_tasks_.end();
205 } 206 }
206 207
207 void SyncTaskManager::DetachFromSequence() { 208 void SyncTaskManager::DetachFromSequence() {
208 sequence_checker_.DetachFromSequence(); 209 sequence_checker_.DetachFromSequence();
209 } 210 }
210 211
211 bool SyncTaskManager::ShouldTrackTaskToken() const { 212 bool SyncTaskManager::ShouldTrackTaskToken() const {
212 return !worker_pool_ || !worker_pool_->IsShutdownInProgress(); 213 return !worker_pool_ || !worker_pool_->IsShutdownInProgress();
213 } 214 }
214 215
(...skipping 18 matching lines...) Expand all
233 } 234 }
234 } 235 }
235 236
236 std::unique_ptr<SyncTask> task; 237 std::unique_ptr<SyncTask> task;
237 SyncStatusCallback callback = token->callback(); 238 SyncStatusCallback callback = token->callback();
238 token->clear_callback(); 239 token->clear_callback();
239 if (token->token_id() == SyncTaskToken::kForegroundTaskTokenID) { 240 if (token->token_id() == SyncTaskToken::kForegroundTaskTokenID) {
240 token_ = std::move(token); 241 token_ = std::move(token);
241 task = std::move(running_foreground_task_); 242 task = std::move(running_foreground_task_);
242 } else { 243 } else {
243 task = running_background_tasks_.take_and_erase(token->token_id()); 244 task = std::move(running_background_tasks_[token->token_id()]);
245 running_background_tasks_.erase(token->token_id());
244 } 246 }
245 247
246 // Acquire the token to prevent a new task to jump into the queue. 248 // Acquire the token to prevent a new task to jump into the queue.
247 token = std::move(token_); 249 token = std::move(token_);
248 250
249 bool task_used_network = false; 251 bool task_used_network = false;
250 if (task) 252 if (task)
251 task_used_network = task->used_network(); 253 task_used_network = task->used_network();
252 254
253 if (client_) 255 if (client_)
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 background_task_token->set_task_blocker(std::move(task_blocker)); 338 background_task_token->set_task_blocker(std::move(task_blocker));
337 } else { 339 } else {
338 tracked_objects::Location from_here = foreground_task_token->location(); 340 tracked_objects::Location from_here = foreground_task_token->location();
339 SyncStatusCallback callback = foreground_task_token->callback(); 341 SyncStatusCallback callback = foreground_task_token->callback();
340 foreground_task_token->clear_callback(); 342 foreground_task_token->clear_callback();
341 343
342 background_task_token = SyncTaskToken::CreateForBackgroundTask( 344 background_task_token = SyncTaskToken::CreateForBackgroundTask(
343 weak_ptr_factory_.GetWeakPtr(), task_runner_.get(), task_token_seq_++, 345 weak_ptr_factory_.GetWeakPtr(), task_runner_.get(), task_token_seq_++,
344 std::move(task_blocker)); 346 std::move(task_blocker));
345 background_task_token->UpdateTask(from_here, callback); 347 background_task_token->UpdateTask(from_here, callback);
346 running_background_tasks_.set(background_task_token->token_id(), 348 running_background_tasks_[background_task_token->token_id()] =
347 std::move(running_foreground_task_)); 349 std::move(running_foreground_task_);
348 } 350 }
349 351
350 token_ = std::move(foreground_task_token); 352 token_ = std::move(foreground_task_token);
351 MaybeStartNextForegroundTask(nullptr); 353 MaybeStartNextForegroundTask(nullptr);
352 background_task_token->SetTaskLog(std::move(task_log)); 354 background_task_token->SetTaskLog(std::move(task_log));
353 continuation.Run(std::move(background_task_token)); 355 continuation.Run(std::move(background_task_token));
354 } 356 }
355 357
356 std::unique_ptr<SyncTaskToken> SyncTaskManager::GetToken( 358 std::unique_ptr<SyncTaskToken> SyncTaskManager::GetToken(
357 const tracked_objects::Location& from_here, 359 const tracked_objects::Location& from_here,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 closure.Run(); 407 closure.Run();
406 return; 408 return;
407 } 409 }
408 410
409 if (client_) 411 if (client_)
410 client_->MaybeScheduleNextTask(); 412 client_->MaybeScheduleNextTask();
411 } 413 }
412 414
413 } // namespace drive_backend 415 } // namespace drive_backend
414 } // namespace sync_file_system 416 } // namespace sync_file_system
OLDNEW
« no previous file with comments | « chrome/browser/sync_file_system/drive_backend/sync_task_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698