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

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

Issue 10539094: NetLogEventParameter to Callback refactoring 1, (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Remove unneeded line Created 8 years, 6 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 "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/file_path.h" 9 #include "base/file_path.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 30 matching lines...) Expand all
41 } 41 }
42 42
43 int RecordAndMapError(int error, 43 int RecordAndMapError(int error,
44 FileErrorSource source, 44 FileErrorSource source,
45 bool record_uma, 45 bool record_uma,
46 const net::BoundNetLog& bound_net_log) { 46 const net::BoundNetLog& bound_net_log) {
47 net::Error net_error = MapSystemError(error); 47 net::Error net_error = MapSystemError(error);
48 48
49 bound_net_log.AddEvent( 49 bound_net_log.AddEvent(
50 net::NetLog::TYPE_FILE_STREAM_ERROR, 50 net::NetLog::TYPE_FILE_STREAM_ERROR,
51 make_scoped_refptr( 51 base::Bind(&NetLogFileStreamErrorCallback,
52 new FileStreamErrorParameters(GetFileErrorSourceName(source), 52 source, error, net_error));
53 error,
54 net_error)));
55 53
56 RecordFileError(error, source, record_uma); 54 RecordFileError(error, source, record_uma);
57 55
58 return net_error; 56 return net_error;
59 } 57 }
60 58
61 // Opens a file with some network logging. 59 // Opens a file with some network logging.
62 // The opened file and the result code are written to |file| and |result|. 60 // The opened file and the result code are written to |file| and |result|.
63 void OpenFile(const FilePath& path, 61 void OpenFile(const FilePath& path,
64 int open_flags, 62 int open_flags,
65 bool record_uma, 63 bool record_uma,
66 base::PlatformFile* file, 64 base::PlatformFile* file,
67 int* result, 65 int* result,
68 const net::BoundNetLog& bound_net_log) { 66 const net::BoundNetLog& bound_net_log) {
67 std::string file_name = path.AsUTF8Unsafe();
69 bound_net_log.BeginEvent( 68 bound_net_log.BeginEvent(
70 net::NetLog::TYPE_FILE_STREAM_OPEN, 69 net::NetLog::TYPE_FILE_STREAM_OPEN,
71 make_scoped_refptr( 70 NetLog::StringCallback("file_name", &file_name));
72 new net::NetLogStringParameter("file_name",
73 path.AsUTF8Unsafe())));
74 71
75 *file = base::CreatePlatformFile(path, open_flags, NULL, NULL); 72 *file = base::CreatePlatformFile(path, open_flags, NULL, NULL);
76 if (*file == base::kInvalidPlatformFileValue) { 73 if (*file == base::kInvalidPlatformFileValue) {
77 DWORD error = GetLastError(); 74 DWORD error = GetLastError();
78 LOG(WARNING) << "Failed to open file: " << error; 75 LOG(WARNING) << "Failed to open file: " << error;
79 *result = RecordAndMapError(error, 76 *result = RecordAndMapError(error,
80 FILE_ERROR_SOURCE_OPEN, 77 FILE_ERROR_SOURCE_OPEN,
81 record_uma, 78 record_uma,
82 bound_net_log); 79 bound_net_log);
83 bound_net_log.EndEvent(net::NetLog::TYPE_FILE_STREAM_OPEN, NULL); 80 bound_net_log.EndEvent(net::NetLog::TYPE_FILE_STREAM_OPEN, NULL);
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 (bound_net_log_.source().id == net::NetLog::Source::kInvalidId)) { 646 (bound_net_log_.source().id == net::NetLog::Source::kInvalidId)) {
650 // Both |BoundNetLog|s are invalid. 647 // Both |BoundNetLog|s are invalid.
651 return; 648 return;
652 } 649 }
653 650
654 // Should never connect to itself. 651 // Should never connect to itself.
655 DCHECK_NE(bound_net_log_.source().id, owner_bound_net_log.source().id); 652 DCHECK_NE(bound_net_log_.source().id, owner_bound_net_log.source().id);
656 653
657 bound_net_log_.AddEvent( 654 bound_net_log_.AddEvent(
658 net::NetLog::TYPE_FILE_STREAM_BOUND_TO_OWNER, 655 net::NetLog::TYPE_FILE_STREAM_BOUND_TO_OWNER,
659 make_scoped_refptr( 656 owner_bound_net_log.source().ToEventParametersCallback());
660 new net::NetLogSourceParameter("source_dependency",
661 owner_bound_net_log.source())));
662 657
663 owner_bound_net_log.AddEvent( 658 owner_bound_net_log.AddEvent(
664 net::NetLog::TYPE_FILE_STREAM_SOURCE, 659 net::NetLog::TYPE_FILE_STREAM_SOURCE,
665 make_scoped_refptr( 660 bound_net_log_.source().ToEventParametersCallback());
666 new net::NetLogSourceParameter("source_dependency",
667 bound_net_log_.source())));
668 } 661 }
669 662
670 base::PlatformFile FileStreamWin::GetPlatformFileForTesting() { 663 base::PlatformFile FileStreamWin::GetPlatformFileForTesting() {
671 return file_; 664 return file_;
672 } 665 }
673 666
674 void FileStreamWin::OnClosed(const CompletionCallback& callback) { 667 void FileStreamWin::OnClosed(const CompletionCallback& callback) {
675 file_ = base::kInvalidPlatformFileValue; 668 file_ = base::kInvalidPlatformFileValue;
676 669
677 // Reset this before Run() as Run() may issue a new async operation. 670 // Reset this before Run() as Run() may issue a new async operation.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 void FileStreamWin::WaitForIOCompletion() { 722 void FileStreamWin::WaitForIOCompletion() {
730 // http://crbug.com/115067 723 // http://crbug.com/115067
731 base::ThreadRestrictions::ScopedAllowWait allow_wait; 724 base::ThreadRestrictions::ScopedAllowWait allow_wait;
732 if (on_io_complete_.get()) { 725 if (on_io_complete_.get()) {
733 on_io_complete_->Wait(); 726 on_io_complete_->Wait();
734 on_io_complete_.reset(); 727 on_io_complete_.reset();
735 } 728 }
736 } 729 }
737 730
738 } // namespace net 731 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698