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

Side by Side Diff: mojo/fetcher/local_fetcher.cc

Issue 1538823002: Convert Pass()→std::move() in mojo/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 | « mojo/fetcher/data_fetcher_unittest.cc ('k') | mojo/fetcher/network_fetcher.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 "mojo/fetcher/local_fetcher.h" 5 #include "mojo/fetcher/local_fetcher.h"
6 6
7 #include <utility>
8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/command_line.h" 10 #include "base/command_line.h"
9 #include "base/files/file_util.h" 11 #include "base/files/file_util.h"
10 #include "base/format_macros.h" 12 #include "base/format_macros.h"
11 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
12 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
13 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
14 #include "base/trace_event/trace_event.h" 16 #include "base/trace_event/trace_event.h"
15 #include "mojo/common/common_type_converters.h" 17 #include "mojo/common/common_type_converters.h"
16 #include "mojo/common/data_pipe_utils.h" 18 #include "mojo/common/data_pipe_utils.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 96
95 GURL LocalFetcher::GetRedirectReferer() const { 97 GURL LocalFetcher::GetRedirectReferer() const {
96 return GURL::EmptyGURL(); 98 return GURL::EmptyGURL();
97 } 99 }
98 100
99 URLResponsePtr LocalFetcher::AsURLResponse(base::TaskRunner* task_runner, 101 URLResponsePtr LocalFetcher::AsURLResponse(base::TaskRunner* task_runner,
100 uint32_t skip) { 102 uint32_t skip) {
101 URLResponsePtr response(URLResponse::New()); 103 URLResponsePtr response(URLResponse::New());
102 response->url = String::From(url_); 104 response->url = String::From(url_);
103 DataPipe data_pipe; 105 DataPipe data_pipe;
104 response->body = data_pipe.consumer_handle.Pass(); 106 response->body = std::move(data_pipe.consumer_handle);
105 int64 file_size; 107 int64 file_size;
106 if (base::GetFileSize(path_, &file_size)) { 108 if (base::GetFileSize(path_, &file_size)) {
107 response->headers = Array<HttpHeaderPtr>(1); 109 response->headers = Array<HttpHeaderPtr>(1);
108 HttpHeaderPtr header = HttpHeader::New(); 110 HttpHeaderPtr header = HttpHeader::New();
109 header->name = "Content-Length"; 111 header->name = "Content-Length";
110 header->value = base::StringPrintf("%" PRId64, file_size); 112 header->value = base::StringPrintf("%" PRId64, file_size);
111 response->headers[0] = header.Pass(); 113 response->headers[0] = std::move(header);
112 } 114 }
113 response->mime_type = String::From(MimeType()); 115 response->mime_type = String::From(MimeType());
114 common::CopyFromFile(path_, data_pipe.producer_handle.Pass(), skip, 116 common::CopyFromFile(path_, std::move(data_pipe.producer_handle), skip,
115 task_runner, base::Bind(&IgnoreResult)); 117 task_runner, base::Bind(&IgnoreResult));
116 return response.Pass(); 118 return response;
117 } 119 }
118 120
119 void LocalFetcher::AsPath( 121 void LocalFetcher::AsPath(
120 base::TaskRunner* task_runner, 122 base::TaskRunner* task_runner,
121 base::Callback<void(const base::FilePath&, bool)> callback) { 123 base::Callback<void(const base::FilePath&, bool)> callback) {
122 // Async for consistency with network case. 124 // Async for consistency with network case.
123 base::MessageLoop::current()->PostTask( 125 base::MessageLoop::current()->PostTask(
124 FROM_HERE, base::Bind(callback, path_, base::PathExists(path_))); 126 FROM_HERE, base::Bind(callback, path_, base::PathExists(path_)));
125 } 127 }
126 128
(...skipping 12 matching lines...) Expand all
139 ReadFileToString(path_, &start_of_file, kMaxShebangLength); 141 ReadFileToString(path_, &start_of_file, kMaxShebangLength);
140 size_t return_position = start_of_file.find('\n'); 142 size_t return_position = start_of_file.find('\n');
141 if (return_position == std::string::npos) 143 if (return_position == std::string::npos)
142 return false; 144 return false;
143 *line = start_of_file.substr(0, return_position + 1); 145 *line = start_of_file.substr(0, return_position + 1);
144 return true; 146 return true;
145 } 147 }
146 148
147 } // namespace fetcher 149 } // namespace fetcher
148 } // namespace mojo 150 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/fetcher/data_fetcher_unittest.cc ('k') | mojo/fetcher/network_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698