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

Side by Side Diff: chrome/browser/extensions/api/braille_display_private/brlapi_connection.cc

Issue 1871713002: Convert //chrome/browser/extensions from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and fix header 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/extensions/api/braille_display_private/brlapi_connectio n.h" 5 #include "chrome/browser/extensions/api/braille_display_private/brlapi_connectio n.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/free_deleter.h" 10 #include "base/memory/free_deleter.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 // MessageLoopForIO::Watcher 50 // MessageLoopForIO::Watcher
51 void OnFileCanReadWithoutBlocking(int fd) override { on_data_ready_.Run(); } 51 void OnFileCanReadWithoutBlocking(int fd) override { on_data_ready_.Run(); }
52 52
53 void OnFileCanWriteWithoutBlocking(int fd) override {} 53 void OnFileCanWriteWithoutBlocking(int fd) override {}
54 54
55 private: 55 private:
56 bool CheckConnected(); 56 bool CheckConnected();
57 ConnectResult ConnectResultForError(); 57 ConnectResult ConnectResultForError();
58 58
59 LibBrlapiLoader* libbrlapi_loader_; 59 LibBrlapiLoader* libbrlapi_loader_;
60 scoped_ptr<brlapi_handle_t, base::FreeDeleter> handle_; 60 std::unique_ptr<brlapi_handle_t, base::FreeDeleter> handle_;
61 MessageLoopForIO::FileDescriptorWatcher fd_controller_; 61 MessageLoopForIO::FileDescriptorWatcher fd_controller_;
62 OnDataReadyCallback on_data_ready_; 62 OnDataReadyCallback on_data_ready_;
63 63
64 DISALLOW_COPY_AND_ASSIGN(BrlapiConnectionImpl); 64 DISALLOW_COPY_AND_ASSIGN(BrlapiConnectionImpl);
65 }; 65 };
66 66
67 BrlapiConnection::BrlapiConnection() { 67 BrlapiConnection::BrlapiConnection() {
68 } 68 }
69 69
70 BrlapiConnection::~BrlapiConnection() { 70 BrlapiConnection::~BrlapiConnection() {
71 } 71 }
72 72
73 scoped_ptr<BrlapiConnection> BrlapiConnection::Create( 73 std::unique_ptr<BrlapiConnection> BrlapiConnection::Create(
74 LibBrlapiLoader* loader) { 74 LibBrlapiLoader* loader) {
75 DCHECK(loader->loaded()); 75 DCHECK(loader->loaded());
76 return scoped_ptr<BrlapiConnection>(new BrlapiConnectionImpl(loader)); 76 return std::unique_ptr<BrlapiConnection>(new BrlapiConnectionImpl(loader));
77 } 77 }
78 78
79 BrlapiConnection::ConnectResult BrlapiConnectionImpl::Connect( 79 BrlapiConnection::ConnectResult BrlapiConnectionImpl::Connect(
80 const OnDataReadyCallback& on_data_ready) { 80 const OnDataReadyCallback& on_data_ready) {
81 DCHECK(!handle_); 81 DCHECK(!handle_);
82 handle_.reset((brlapi_handle_t*) malloc( 82 handle_.reset((brlapi_handle_t*) malloc(
83 libbrlapi_loader_->brlapi_getHandleSize())); 83 libbrlapi_loader_->brlapi_getHandleSize()));
84 int fd = libbrlapi_loader_->brlapi__openConnection(handle_.get(), NULL, NULL); 84 int fd = libbrlapi_loader_->brlapi__openConnection(handle_.get(), NULL, NULL);
85 if (fd < 0) { 85 if (fd < 0) {
86 handle_.reset(); 86 handle_.reset();
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 if (error->brlerrno == BRLAPI_ERROR_LIBCERR 210 if (error->brlerrno == BRLAPI_ERROR_LIBCERR
211 && error->libcerrno == ENOENT) { 211 && error->libcerrno == ENOENT) {
212 return CONNECT_ERROR_NO_RETRY; 212 return CONNECT_ERROR_NO_RETRY;
213 } 213 }
214 return CONNECT_ERROR_RETRY; 214 return CONNECT_ERROR_RETRY;
215 } 215 }
216 216
217 } // namespace braille_display_private 217 } // namespace braille_display_private
218 } // namespace api 218 } // namespace api
219 } // namespace extensions 219 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698