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

Side by Side Diff: chrome/browser/sessions/base_session_service.cc

Issue 22363005: Switch BaseSessionService to use SequencedWorkerPool instead of FILE thread (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/sessions/base_session_service.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 (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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 70
71 // static 71 // static
72 const int BaseSessionService::max_persist_navigation_count = 6; 72 const int BaseSessionService::max_persist_navigation_count = 6;
73 73
74 BaseSessionService::BaseSessionService(SessionType type, 74 BaseSessionService::BaseSessionService(SessionType type,
75 Profile* profile, 75 Profile* profile,
76 const base::FilePath& path) 76 const base::FilePath& path)
77 : profile_(profile), 77 : profile_(profile),
78 weak_factory_(this), 78 weak_factory_(this),
79 pending_reset_(false), 79 pending_reset_(false),
80 commands_since_reset_(0) { 80 commands_since_reset_(0),
81 sequence_token_(
82 content::BrowserThread::GetBlockingPool()->GetSequenceToken()) {
81 if (profile) { 83 if (profile) {
82 // We should never be created when incognito. 84 // We should never be created when incognito.
83 DCHECK(!profile->IsOffTheRecord()); 85 DCHECK(!profile->IsOffTheRecord());
84 } 86 }
85 backend_ = new SessionBackend(type, profile_ ? profile_->GetPath() : path); 87 backend_ = new SessionBackend(type, profile_ ? profile_->GetPath() : path);
86 DCHECK(backend_.get()); 88 DCHECK(backend_.get());
87 89
88 // SessionBackend::Init() cannot be scheduled to be called here. There are 90 // SessionBackend::Init() cannot be scheduled to be called here. There are
89 // service processes which create the BaseSessionService, but they should not 91 // service processes which create the BaseSessionService, but they should not
90 // initialize the backend. If they do, the backend will cycle the session 92 // initialize the backend. If they do, the backend will cycle the session
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 RunTaskOnBackendThread( 294 RunTaskOnBackendThread(
293 FROM_HERE, 295 FROM_HERE,
294 base::Bind(&SessionBackend::ReadLastSessionCommands, backend(), 296 base::Bind(&SessionBackend::ReadLastSessionCommands, backend(),
295 is_canceled, callback_runner)); 297 is_canceled, callback_runner));
296 return id; 298 return id;
297 } 299 }
298 300
299 bool BaseSessionService::RunTaskOnBackendThread( 301 bool BaseSessionService::RunTaskOnBackendThread(
300 const tracked_objects::Location& from_here, 302 const tracked_objects::Location& from_here,
301 const base::Closure& task) { 303 const base::Closure& task) {
302 if (profile_ && BrowserThread::IsMessageLoopValid(BrowserThread::FILE)) { 304 if (RunningInProduction()) {
303 return BrowserThread::PostTask(BrowserThread::FILE, from_here, task); 305 return content::BrowserThread::GetBlockingPool()->
306 PostSequencedWorkerTask(sequence_token_,
307 from_here,
308 task);
304 } else { 309 } else {
305 // Fall back to executing on the main thread if the file thread 310 // Fall back to executing on the main thread if the sequence
306 // has gone away (around shutdown time) or if we're running as 311 // worker pool has been requested to shutdown (around shutdown
307 // part of a unit test that does not set profile_. 312 // time) or if we're running as part of a unit test that does not
313 // set profile_.
308 task.Run(); 314 task.Run();
309 return true; 315 return true;
310 } 316 }
311 } 317 }
312 318
313 bool BaseSessionService::RunningInProduction() const { 319 bool BaseSessionService::RunningInProduction() const {
314 return profile_ && BrowserThread::IsMessageLoopValid(BrowserThread::FILE); 320 base::SequencedWorkerPool* pool = content::BrowserThread::GetBlockingPool();
321 return profile_ && !pool->IsShutdownInProgress();
marja 2013/08/08 20:16:43 Why checking IsShutdownInProgress here? Will that
oshima 2013/08/08 20:36:53 This is just replacement of BrowserThread::IsMessa
315 } 322 }
OLDNEW
« no previous file with comments | « chrome/browser/sessions/base_session_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698