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

Side by Side Diff: components/sessions/core/session_backend.cc

Issue 1912843002: Convert //components/sessions from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 "components/sessions/core/session_backend.h" 5 #include "components/sessions/core/session_backend.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <limits> 8 #include <limits>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 // errored_ is set to true. 73 // errored_ is set to true.
74 bool FillBuffer(); 74 bool FillBuffer();
75 75
76 // Whether an error condition has been detected ( 76 // Whether an error condition has been detected (
77 bool errored_; 77 bool errored_;
78 78
79 // As we read from the file, data goes here. 79 // As we read from the file, data goes here.
80 std::string buffer_; 80 std::string buffer_;
81 81
82 // The file. 82 // The file.
83 scoped_ptr<base::File> file_; 83 std::unique_ptr<base::File> file_;
84 84
85 // Position in buffer_ of the data. 85 // Position in buffer_ of the data.
86 size_t buffer_position_; 86 size_t buffer_position_;
87 87
88 // Number of available bytes; relative to buffer_position_. 88 // Number of available bytes; relative to buffer_position_.
89 size_t available_count_; 89 size_t available_count_;
90 90
91 DISALLOW_COPY_AND_ASSIGN(SessionFileReader); 91 DISALLOW_COPY_AND_ASSIGN(SessionFileReader);
92 }; 92 };
93 93
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 !current_session_file_->SetLength(header_size)) 367 !current_session_file_->SetLength(header_size))
368 current_session_file_.reset(NULL); 368 current_session_file_.reset(NULL);
369 } 369 }
370 if (!current_session_file_.get()) 370 if (!current_session_file_.get())
371 current_session_file_.reset(OpenAndWriteHeader(GetCurrentSessionPath())); 371 current_session_file_.reset(OpenAndWriteHeader(GetCurrentSessionPath()));
372 empty_file_ = true; 372 empty_file_ = true;
373 } 373 }
374 374
375 base::File* SessionBackend::OpenAndWriteHeader(const base::FilePath& path) { 375 base::File* SessionBackend::OpenAndWriteHeader(const base::FilePath& path) {
376 DCHECK(!path.empty()); 376 DCHECK(!path.empty());
377 scoped_ptr<base::File> file(new base::File( 377 std::unique_ptr<base::File> file(new base::File(
378 path, 378 path, base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE |
379 base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE | 379 base::File::FLAG_EXCLUSIVE_WRITE |
380 base::File::FLAG_EXCLUSIVE_WRITE | base::File::FLAG_EXCLUSIVE_READ)); 380 base::File::FLAG_EXCLUSIVE_READ));
381 if (!file->IsValid()) 381 if (!file->IsValid())
382 return NULL; 382 return NULL;
383 FileHeader header; 383 FileHeader header;
384 header.signature = kFileSignature; 384 header.signature = kFileSignature;
385 header.version = kFileCurrentVersion; 385 header.version = kFileCurrentVersion;
386 int wrote = file->WriteAtCurrentPos(reinterpret_cast<char*>(&header), 386 int wrote = file->WriteAtCurrentPos(reinterpret_cast<char*>(&header),
387 sizeof(header)); 387 sizeof(header));
388 if (wrote != sizeof(header)) 388 if (wrote != sizeof(header))
389 return NULL; 389 return NULL;
390 return file.release(); 390 return file.release();
(...skipping 11 matching lines...) Expand all
402 base::FilePath SessionBackend::GetCurrentSessionPath() { 402 base::FilePath SessionBackend::GetCurrentSessionPath() {
403 base::FilePath path = path_to_dir_; 403 base::FilePath path = path_to_dir_;
404 if (type_ == sessions::BaseSessionService::TAB_RESTORE) 404 if (type_ == sessions::BaseSessionService::TAB_RESTORE)
405 path = path.AppendASCII(kCurrentTabSessionFileName); 405 path = path.AppendASCII(kCurrentTabSessionFileName);
406 else 406 else
407 path = path.AppendASCII(kCurrentSessionFileName); 407 path = path.AppendASCII(kCurrentSessionFileName);
408 return path; 408 return path;
409 } 409 }
410 410
411 } // namespace sessions 411 } // namespace sessions
OLDNEW
« no previous file with comments | « components/sessions/core/session_backend.h ('k') | components/sessions/core/session_service_commands.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698