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

Side by Side Diff: services/native_support/redirectors.cc

Issue 1397133002: Remove callers of mojo::Array<size_t> constructor in favor of ::New (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 2 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 | « services/js/system/tests/js_to_cpp_tests.cc ('k') | services/reaper/reaper_impl.cc » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "services/native_support/redirectors.h" 5 #include "services/native_support/redirectors.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 70
71 void FDToMojoFileRedirector::OnFileCanWriteWithoutBlocking(int /*fd*/) { 71 void FDToMojoFileRedirector::OnFileCanWriteWithoutBlocking(int /*fd*/) {
72 NOTREACHED(); 72 NOTREACHED();
73 } 73 }
74 74
75 void FDToMojoFileRedirector::DoWrite() { 75 void FDToMojoFileRedirector::DoWrite() {
76 CHECK_GT(num_bytes_, offset_); 76 CHECK_GT(num_bytes_, offset_);
77 size_t num_bytes_to_write = num_bytes_ - offset_; 77 size_t num_bytes_to_write = num_bytes_ - offset_;
78 78
79 // TODO(vtl): Is there a more natural (or efficient) way to do this? 79 // TODO(vtl): Is there a more natural (or efficient) way to do this?
80 mojo::Array<uint8_t> bytes_to_write(num_bytes_to_write); 80 auto bytes_to_write = mojo::Array<uint8_t>::New(num_bytes_to_write);
81 memcpy(&bytes_to_write[offset_], buffer_.get(), num_bytes_to_write); 81 memcpy(&bytes_to_write[offset_], buffer_.get(), num_bytes_to_write);
82 82
83 file_->Write(bytes_to_write.Pass(), 0, mojo::files::Whence::FROM_CURRENT, 83 file_->Write(bytes_to_write.Pass(), 0, mojo::files::Whence::FROM_CURRENT,
84 base::Bind(&FDToMojoFileRedirector::DidWrite, 84 base::Bind(&FDToMojoFileRedirector::DidWrite,
85 weak_factory_.GetWeakPtr())); 85 weak_factory_.GetWeakPtr()));
86 } 86 }
87 87
88 void FDToMojoFileRedirector::DidWrite(mojo::files::Error error, 88 void FDToMojoFileRedirector::DidWrite(mojo::files::Error error,
89 uint32_t num_bytes_written) { 89 uint32_t num_bytes_written) {
90 if (error != mojo::files::Error::OK) { 90 if (error != mojo::files::Error::OK) {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 return; 164 return;
165 } 165 }
166 if (static_cast<size_t>(result) != bytes_read.size()) 166 if (static_cast<size_t>(result) != bytes_read.size())
167 LOG(ERROR) << "Failed to write everything to FD"; 167 LOG(ERROR) << "Failed to write everything to FD";
168 168
169 if (running_) 169 if (running_)
170 Start(); 170 Start();
171 } 171 }
172 172
173 } // namespace native_support 173 } // namespace native_support
OLDNEW
« no previous file with comments | « services/js/system/tests/js_to_cpp_tests.cc ('k') | services/reaper/reaper_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698