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

Side by Side Diff: chrome_frame/test/test_server.cc

Issue 12321062: base: Move MemoryMappedFile out of file_util.h and into its own header file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix chrome_frame Created 7 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "chrome_frame/test/test_server.h"
6
5 #include <windows.h> 7 #include <windows.h>
6 #include <objbase.h> 8 #include <objbase.h>
7 #include <urlmon.h> 9 #include <urlmon.h>
8 10
9 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/files/memory_mapped_file.h"
10 #include "base/logging.h" 13 #include "base/logging.h"
11 #include "base/string_number_conversions.h" 14 #include "base/string_number_conversions.h"
12 #include "base/string_piece.h" 15 #include "base/string_piece.h"
13 #include "base/string_util.h" 16 #include "base/string_util.h"
14 #include "base/stringprintf.h" 17 #include "base/stringprintf.h"
15 #include "base/utf_string_conversions.h" 18 #include "base/utf_string_conversions.h"
16 #include "chrome_frame/test/chrome_frame_test_utils.h" 19 #include "chrome_frame/test/chrome_frame_test_utils.h"
17 #include "chrome_frame/test/test_server.h"
18 #include "net/base/tcp_listen_socket.h" 20 #include "net/base/tcp_listen_socket.h"
19 #include "net/base/winsock_init.h" 21 #include "net/base/winsock_init.h"
20 #include "net/http/http_util.h" 22 #include "net/http/http_util.h"
21 23
22 namespace test_server { 24 namespace test_server {
23 const char kDefaultHeaderTemplate[] = 25 const char kDefaultHeaderTemplate[] =
24 "HTTP/1.1 %hs\r\n" 26 "HTTP/1.1 %hs\r\n"
25 "Connection: close\r\n" 27 "Connection: close\r\n"
26 "Content-Type: %hs\r\n" 28 "Content-Type: %hs\r\n"
27 "Content-Length: %i\r\n\r\n"; 29 "Content-Length: %i\r\n\r\n";
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 void FileResponse::WriteContents(net::StreamListenSocket* socket) const { 112 void FileResponse::WriteContents(net::StreamListenSocket* socket) const {
111 DCHECK(file_.get()); 113 DCHECK(file_.get());
112 if (file_.get()) { 114 if (file_.get()) {
113 socket->Send(reinterpret_cast<const char*>(file_->data()), 115 socket->Send(reinterpret_cast<const char*>(file_->data()),
114 file_->length(), false); 116 file_->length(), false);
115 } 117 }
116 } 118 }
117 119
118 size_t FileResponse::ContentLength() const { 120 size_t FileResponse::ContentLength() const {
119 if (file_.get() == NULL) { 121 if (file_.get() == NULL) {
120 file_.reset(new file_util::MemoryMappedFile()); 122 file_.reset(new base::MemoryMappedFile());
121 if (!file_->Initialize(file_path_)) { 123 if (!file_->Initialize(file_path_)) {
122 NOTREACHED(); 124 NOTREACHED();
123 file_.reset(); 125 file_.reset();
124 } 126 }
125 } 127 }
126 return file_.get() ? file_->length() : 0; 128 return file_.get() ? file_->length() : 0;
127 } 129 }
128 130
129 bool RedirectResponse::GetCustomHeaders(std::string* headers) const { 131 bool RedirectResponse::GetCustomHeaders(std::string* headers) const {
130 *headers = base::StringPrintf("HTTP/1.1 302 Found\r\n" 132 *headers = base::StringPrintf("HTTP/1.1 302 Found\r\n"
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 data_.append(content_length_header); 412 data_.append(content_length_header);
411 data_.append("\r\n"); 413 data_.append("\r\n");
412 } 414 }
413 415
414 MessageLoop::current()->PostDelayedTask( 416 MessageLoop::current()->PostDelayedTask(
415 FROM_HERE, base::Bind(&ConfigurableConnection::SendChunk, this), 417 FROM_HERE, base::Bind(&ConfigurableConnection::SendChunk, this),
416 base::TimeDelta::FromMilliseconds(options.timeout_)); 418 base::TimeDelta::FromMilliseconds(options.timeout_));
417 } 419 }
418 420
419 } // namespace test_server 421 } // namespace test_server
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698