OLD | NEW |
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_token.h" | 5 #include "chrome/browser/sync_file_system/drive_backend/sync_task_token.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/thread_task_runner_handle.h" | 9 #include "base/thread_task_runner_handle.h" |
10 #include "chrome/browser/sync_file_system/drive_backend/sync_task_manager.h" | 10 #include "chrome/browser/sync_file_system/drive_backend/sync_task_manager.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 callback_ = callback; | 61 callback_ = callback; |
62 DVLOG(2) << "Token updated: " << location_.ToString(); | 62 DVLOG(2) << "Token updated: " << location_.ToString(); |
63 } | 63 } |
64 | 64 |
65 SyncTaskToken::~SyncTaskToken() { | 65 SyncTaskToken::~SyncTaskToken() { |
66 // All task on Client must hold TaskToken instance to ensure | 66 // All task on Client must hold TaskToken instance to ensure |
67 // no other tasks are running. Also, as soon as a task finishes to work, | 67 // no other tasks are running. Also, as soon as a task finishes to work, |
68 // it must return the token to TaskManager. | 68 // it must return the token to TaskManager. |
69 // Destroying a token with valid |client| indicates the token was | 69 // Destroying a token with valid |client| indicates the token was |
70 // dropped by a task without returning. | 70 // dropped by a task without returning. |
71 if (task_runner_ && task_runner_->RunsTasksOnCurrentThread() && | 71 if (task_runner_.get() && task_runner_->RunsTasksOnCurrentThread() && |
72 manager_ && manager_->IsRunningTask(token_id_)) { | 72 manager_ && manager_->IsRunningTask(token_id_)) { |
73 NOTREACHED() | 73 NOTREACHED() |
74 << "Unexpected TaskToken deletion from: " << location_.ToString(); | 74 << "Unexpected TaskToken deletion from: " << location_.ToString(); |
75 | 75 |
76 // Reinitializes the token. | 76 // Reinitializes the token. |
77 SyncTaskManager::NotifyTaskDone( | 77 SyncTaskManager::NotifyTaskDone( |
78 make_scoped_ptr(new SyncTaskToken( | 78 make_scoped_ptr(new SyncTaskToken(manager_, |
79 manager_, task_runner_, token_id_, blocking_factor_.Pass(), | 79 task_runner_.get(), |
80 SyncStatusCallback())), | 80 token_id_, |
| 81 blocking_factor_.Pass(), |
| 82 SyncStatusCallback())), |
81 SYNC_STATUS_OK); | 83 SYNC_STATUS_OK); |
82 } | 84 } |
83 } | 85 } |
84 | 86 |
85 // static | 87 // static |
86 SyncStatusCallback SyncTaskToken::WrapToCallback( | 88 SyncStatusCallback SyncTaskToken::WrapToCallback( |
87 scoped_ptr<SyncTaskToken> token) { | 89 scoped_ptr<SyncTaskToken> token) { |
88 return base::Bind(&SyncTaskManager::NotifyTaskDone, base::Passed(&token)); | 90 return base::Bind(&SyncTaskManager::NotifyTaskDone, base::Passed(&token)); |
89 } | 91 } |
90 | 92 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 const SyncStatusCallback& callback) | 145 const SyncStatusCallback& callback) |
144 : manager_(manager), | 146 : manager_(manager), |
145 task_runner_(task_runner), | 147 task_runner_(task_runner), |
146 token_id_(token_id), | 148 token_id_(token_id), |
147 callback_(callback), | 149 callback_(callback), |
148 blocking_factor_(blocking_factor.Pass()) { | 150 blocking_factor_(blocking_factor.Pass()) { |
149 } | 151 } |
150 | 152 |
151 } // namespace drive_backend | 153 } // namespace drive_backend |
152 } // namespace sync_file_system | 154 } // namespace sync_file_system |
OLD | NEW |