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

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

Issue 3296003: FBTF: Move the TabRestoreService::Observer into its own file. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: More mac fixes Created 10 years, 3 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/sessions/session_backend.h ('k') | chrome/browser/sessions/session_types.h » ('j') | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/session_backend.h" 5 #include "chrome/browser/sessions/session_backend.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/histogram.h" 10 #include "base/histogram.h"
11 #include "base/scoped_vector.h" 11 #include "base/scoped_vector.h"
12 #include "net/base/file_stream.h"
12 13
13 using base::TimeTicks; 14 using base::TimeTicks;
14 15
15 // File version number. 16 // File version number.
16 static const int32 kFileCurrentVersion = 1; 17 static const int32 kFileCurrentVersion = 1;
17 18
18 // The signature at the beginning of the file = SSNS (Sessions). 19 // The signature at the beginning of the file = SSNS (Sessions).
19 static const int32 kFileSignature = 0x53534E53; 20 static const int32 kFileSignature = 0x53534E53;
20 21
21 namespace { 22 namespace {
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 content_size, NULL); 329 content_size, NULL);
329 if (wrote != content_size) { 330 if (wrote != content_size) {
330 NOTREACHED() << "error writing"; 331 NOTREACHED() << "error writing";
331 return false; 332 return false;
332 } 333 }
333 } 334 }
334 } 335 }
335 return true; 336 return true;
336 } 337 }
337 338
339 SessionBackend::~SessionBackend() {
340 }
341
338 void SessionBackend::ResetFile() { 342 void SessionBackend::ResetFile() {
339 DCHECK(inited_); 343 DCHECK(inited_);
340 if (current_session_file_.get()) { 344 if (current_session_file_.get()) {
341 // File is already open, truncate it. We truncate instead of closing and 345 // File is already open, truncate it. We truncate instead of closing and
342 // reopening to avoid the possibility of scanners locking the file out 346 // reopening to avoid the possibility of scanners locking the file out
343 // from under us once we close it. If truncation fails, we'll try to 347 // from under us once we close it. If truncation fails, we'll try to
344 // recreate. 348 // recreate.
345 if (current_session_file_->Truncate(sizeof_header()) != sizeof_header()) 349 if (current_session_file_->Truncate(sizeof_header()) != sizeof_header())
346 current_session_file_.reset(NULL); 350 current_session_file_.reset(NULL);
347 } 351 }
(...skipping 30 matching lines...) Expand all
378 } 382 }
379 383
380 FilePath SessionBackend::GetCurrentSessionPath() { 384 FilePath SessionBackend::GetCurrentSessionPath() {
381 FilePath path = path_to_dir_; 385 FilePath path = path_to_dir_;
382 if (type_ == BaseSessionService::TAB_RESTORE) 386 if (type_ == BaseSessionService::TAB_RESTORE)
383 path = path.AppendASCII(kCurrentTabSessionFileName); 387 path = path.AppendASCII(kCurrentTabSessionFileName);
384 else 388 else
385 path = path.AppendASCII(kCurrentSessionFileName); 389 path = path.AppendASCII(kCurrentSessionFileName);
386 return path; 390 return path;
387 } 391 }
OLDNEW
« no previous file with comments | « chrome/browser/sessions/session_backend.h ('k') | chrome/browser/sessions/session_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698