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

Side by Side Diff: net/base/file_stream_win.cc

Issue 18764: Change FileStream to use FilePath instead of wstring. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 11 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
« no previous file with comments | « net/base/file_stream_unittest.cc ('k') | net/base/upload_data_stream.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 (c) 2008 The Chromium Authors. All rights reserved. Use of this 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the 2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file. 3 // LICENSE file.
4 4
5 #include "net/base/file_stream.h" 5 #include "net/base/file_stream.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 if (file_ != INVALID_HANDLE_VALUE) 118 if (file_ != INVALID_HANDLE_VALUE)
119 CancelIo(file_); 119 CancelIo(file_);
120 120
121 async_context_.reset(); 121 async_context_.reset();
122 if (file_ != INVALID_HANDLE_VALUE) { 122 if (file_ != INVALID_HANDLE_VALUE) {
123 CloseHandle(file_); 123 CloseHandle(file_);
124 file_ = INVALID_HANDLE_VALUE; 124 file_ = INVALID_HANDLE_VALUE;
125 } 125 }
126 } 126 }
127 127
128 int FileStream::Open(const std::wstring& path, int open_flags) { 128 int FileStream::Open(const FilePath& path, int open_flags) {
129 if (IsOpen()) { 129 if (IsOpen()) {
130 DLOG(FATAL) << "File is already open!"; 130 DLOG(FATAL) << "File is already open!";
131 return ERR_UNEXPECTED; 131 return ERR_UNEXPECTED;
132 } 132 }
133 133
134 open_flags_ = open_flags; 134 open_flags_ = open_flags;
135 file_ = base::CreatePlatformFile(path, open_flags_, NULL); 135 file_ = base::CreatePlatformFile(path.value(), open_flags_, NULL);
136 if (file_ == INVALID_HANDLE_VALUE) { 136 if (file_ == INVALID_HANDLE_VALUE) {
137 DWORD error = GetLastError(); 137 DWORD error = GetLastError();
138 LOG(WARNING) << "Failed to open file: " << error; 138 LOG(WARNING) << "Failed to open file: " << error;
139 return MapErrorCode(error); 139 return MapErrorCode(error);
140 } 140 }
141 141
142 if (open_flags_ & base::PLATFORM_FILE_ASYNC) { 142 if (open_flags_ & base::PLATFORM_FILE_ASYNC) {
143 async_context_.reset(new AsyncContext(this)); 143 async_context_.reset(new AsyncContext(this));
144 MessageLoopForIO::current()->RegisterIOHandler(file_, 144 MessageLoopForIO::current()->RegisterIOHandler(file_,
145 async_context_.get()); 145 async_context_.get());
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 async_context_->IOCompletionIsPending(callback); 250 async_context_->IOCompletionIsPending(callback);
251 rv = ERR_IO_PENDING; 251 rv = ERR_IO_PENDING;
252 } else { 252 } else {
253 rv = static_cast<int>(bytes_written); 253 rv = static_cast<int>(bytes_written);
254 } 254 }
255 return rv; 255 return rv;
256 } 256 }
257 257
258 } // namespace net 258 } // namespace net
259 259
OLDNEW
« no previous file with comments | « net/base/file_stream_unittest.cc ('k') | net/base/upload_data_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698