OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/pickle.h" | 9 #include "base/pickle.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 *bytes_written += num_bytes; | 36 *bytes_written += num_bytes; |
37 pickle.WriteString(str); | 37 pickle.WriteString(str); |
38 } else { | 38 } else { |
39 pickle.WriteString(std::string()); | 39 pickle.WriteString(std::string()); |
40 } | 40 } |
41 } | 41 } |
42 | 42 |
43 // Helper used by ScheduleGetLastSessionCommands. It runs callback on TaskRunner | 43 // Helper used by ScheduleGetLastSessionCommands. It runs callback on TaskRunner |
44 // thread if it's not canceled. | 44 // thread if it's not canceled. |
45 void RunIfNotCanceled( | 45 void RunIfNotCanceled( |
46 const CancelableTaskTracker::IsCanceledCallback& is_canceled, | 46 const base::CancelableTaskTracker::IsCanceledCallback& is_canceled, |
47 const BaseSessionService::InternalGetCommandsCallback& callback, | 47 const BaseSessionService::InternalGetCommandsCallback& callback, |
48 ScopedVector<SessionCommand> commands) { | 48 ScopedVector<SessionCommand> commands) { |
49 if (is_canceled.Run()) | 49 if (is_canceled.Run()) |
50 return; | 50 return; |
51 callback.Run(commands.Pass()); | 51 callback.Run(commands.Pass()); |
52 } | 52 } |
53 | 53 |
54 void PostOrRunInternalGetCommandsCallback( | 54 void PostOrRunInternalGetCommandsCallback( |
55 base::TaskRunner* task_runner, | 55 base::TaskRunner* task_runner, |
56 const BaseSessionService::InternalGetCommandsCallback& callback, | 56 const BaseSessionService::InternalGetCommandsCallback& callback, |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 } | 265 } |
266 | 266 |
267 bool BaseSessionService::ShouldTrackEntry(const GURL& url) { | 267 bool BaseSessionService::ShouldTrackEntry(const GURL& url) { |
268 // Blacklist chrome://quit and chrome://restart to avoid quit or restart | 268 // Blacklist chrome://quit and chrome://restart to avoid quit or restart |
269 // loops. | 269 // loops. |
270 return url.is_valid() && !(url.SchemeIs(chrome::kChromeUIScheme) && | 270 return url.is_valid() && !(url.SchemeIs(chrome::kChromeUIScheme) && |
271 (url.host() == chrome::kChromeUIQuitHost || | 271 (url.host() == chrome::kChromeUIQuitHost || |
272 url.host() == chrome::kChromeUIRestartHost)); | 272 url.host() == chrome::kChromeUIRestartHost)); |
273 } | 273 } |
274 | 274 |
275 CancelableTaskTracker::TaskId | 275 base::CancelableTaskTracker::TaskId |
276 BaseSessionService::ScheduleGetLastSessionCommands( | 276 BaseSessionService::ScheduleGetLastSessionCommands( |
277 const InternalGetCommandsCallback& callback, | 277 const InternalGetCommandsCallback& callback, |
278 CancelableTaskTracker* tracker) { | 278 base::CancelableTaskTracker* tracker) { |
279 CancelableTaskTracker::IsCanceledCallback is_canceled; | 279 base::CancelableTaskTracker::IsCanceledCallback is_canceled; |
280 CancelableTaskTracker::TaskId id = tracker->NewTrackedTaskId(&is_canceled); | 280 base::CancelableTaskTracker::TaskId id = |
| 281 tracker->NewTrackedTaskId(&is_canceled); |
281 | 282 |
282 InternalGetCommandsCallback run_if_not_canceled = | 283 InternalGetCommandsCallback run_if_not_canceled = |
283 base::Bind(&RunIfNotCanceled, is_canceled, callback); | 284 base::Bind(&RunIfNotCanceled, is_canceled, callback); |
284 | 285 |
285 InternalGetCommandsCallback callback_runner = | 286 InternalGetCommandsCallback callback_runner = |
286 base::Bind(&PostOrRunInternalGetCommandsCallback, | 287 base::Bind(&PostOrRunInternalGetCommandsCallback, |
287 base::MessageLoopProxy::current(), run_if_not_canceled); | 288 base::MessageLoopProxy::current(), run_if_not_canceled); |
288 | 289 |
289 RunTaskOnBackendThread( | 290 RunTaskOnBackendThread( |
290 FROM_HERE, | 291 FROM_HERE, |
(...skipping 12 matching lines...) Expand all Loading... |
303 from_here, | 304 from_here, |
304 task); | 305 task); |
305 } else { | 306 } else { |
306 // Fall back to executing on the main thread if the sequence | 307 // Fall back to executing on the main thread if the sequence |
307 // worker pool has been requested to shutdown (around shutdown | 308 // worker pool has been requested to shutdown (around shutdown |
308 // time). | 309 // time). |
309 task.Run(); | 310 task.Run(); |
310 return true; | 311 return true; |
311 } | 312 } |
312 } | 313 } |
OLD | NEW |