OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/sessions/base_session_service.h" | 5 #include "chrome/browser/sessions/base_session_service.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/pickle.h" | 8 #include "base/pickle.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 CancelableRequestConsumerBase* consumer) { | 268 CancelableRequestConsumerBase* consumer) { |
269 scoped_refptr<InternalGetCommandsRequest> request_wrapper(request); | 269 scoped_refptr<InternalGetCommandsRequest> request_wrapper(request); |
270 AddRequest(request, consumer); | 270 AddRequest(request, consumer); |
271 RunTaskOnBackendThread( | 271 RunTaskOnBackendThread( |
272 FROM_HERE, | 272 FROM_HERE, |
273 base::Bind(&SessionBackend::ReadLastSessionCommands, backend(), | 273 base::Bind(&SessionBackend::ReadLastSessionCommands, backend(), |
274 request_wrapper)); | 274 request_wrapper)); |
275 return request->handle(); | 275 return request->handle(); |
276 } | 276 } |
277 | 277 |
278 BaseSessionService::Handle | |
279 BaseSessionService::ScheduleGetCurrentSessionCommands( | |
280 InternalGetCommandsRequest* request, | |
281 CancelableRequestConsumerBase* consumer) { | |
282 scoped_refptr<InternalGetCommandsRequest> request_wrapper(request); | |
283 AddRequest(request, consumer); | |
284 RunTaskOnBackendThread( | |
285 FROM_HERE, | |
286 base::Bind(&SessionBackend::ReadCurrentSessionCommands, backend(), | |
287 request_wrapper)); | |
288 return request->handle(); | |
289 } | |
290 | |
291 bool BaseSessionService::RunTaskOnBackendThread( | 278 bool BaseSessionService::RunTaskOnBackendThread( |
292 const tracked_objects::Location& from_here, | 279 const tracked_objects::Location& from_here, |
293 const base::Closure& task) { | 280 const base::Closure& task) { |
294 if (profile_ && BrowserThread::IsMessageLoopValid(BrowserThread::FILE)) { | 281 if (profile_ && BrowserThread::IsMessageLoopValid(BrowserThread::FILE)) { |
295 return BrowserThread::PostTask(BrowserThread::FILE, from_here, task); | 282 return BrowserThread::PostTask(BrowserThread::FILE, from_here, task); |
296 } else { | 283 } else { |
297 // Fall back to executing on the main thread if the file thread | 284 // Fall back to executing on the main thread if the file thread |
298 // has gone away (around shutdown time) or if we're running as | 285 // has gone away (around shutdown time) or if we're running as |
299 // part of a unit test that does not set profile_. | 286 // part of a unit test that does not set profile_. |
300 task.Run(); | 287 task.Run(); |
301 return true; | 288 return true; |
302 } | 289 } |
303 } | 290 } |
OLD | NEW |