diff options
author | ahendrickson@chromium.org <ahendrickson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-02 18:49:43 +0000 |
---|---|---|
committer | ahendrickson@chromium.org <ahendrickson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-02 18:49:43 +0000 |
commit | 1034299e794d0ba846309c43046eb8bb8a740e27 (patch) | |
tree | 9844e4cfd15857aa0d772432f8cd01983bc1df56 /chrome/browser | |
parent | e5eed6d9790191c9ce4705167d1bb1166d521699 (diff) | |
download | chromium_src-1034299e794d0ba846309c43046eb8bb8a740e27.zip chromium_src-1034299e794d0ba846309c43046eb8bb8a740e27.tar.gz chromium_src-1034299e794d0ba846309c43046eb8bb8a740e27.tar.bz2 |
Added Net logging to FileStream.
The net logging doesn't currently do anything, but is ready if some system wants to pass it in.
This is the first of 4 CLs that will enable net logging for downloads.
BUG=None
TEST=None
Review URL: https://chromiumcodereview.appspot.com/9288084
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@120226 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/bookmarks/bookmark_html_writer.cc | 5 | ||||
-rw-r--r-- | chrome/browser/chromeos/imageburner/burn_manager.cc | 2 | ||||
-rw-r--r-- | chrome/browser/net/passive_log_collector.cc | 29 | ||||
-rw-r--r-- | chrome/browser/net/passive_log_collector.h | 16 | ||||
-rw-r--r-- | chrome/browser/resources/net_internals/events_view.css | 4 | ||||
-rw-r--r-- | chrome/browser/resources/net_internals/source_entry.js | 21 | ||||
-rw-r--r-- | chrome/browser/safe_browsing/bloom_filter.cc | 6 | ||||
-rw-r--r-- | chrome/browser/sessions/session_backend.cc | 6 | ||||
-rw-r--r-- | chrome/browser/themes/browser_theme_pack.cc | 4 |
9 files changed, 82 insertions, 11 deletions
diff --git a/chrome/browser/bookmarks/bookmark_html_writer.cc b/chrome/browser/bookmarks/bookmark_html_writer.cc index c933680..8ab2de4 100644 --- a/chrome/browser/bookmarks/bookmark_html_writer.cc +++ b/chrome/browser/bookmarks/bookmark_html_writer.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -93,7 +93,8 @@ class Writer : public base::RefCountedThreadSafe<Writer> { : bookmarks_(bookmarks), path_(path), favicons_map_(favicons_map), - observer_(observer) { + observer_(observer), + file_stream_(NULL) { } // Writing bookmarks and favicons data to file. diff --git a/chrome/browser/chromeos/imageburner/burn_manager.cc b/chrome/browser/chromeos/imageburner/burn_manager.cc index 7154c16..3b8db3f 100644 --- a/chrome/browser/chromeos/imageburner/burn_manager.cc +++ b/chrome/browser/chromeos/imageburner/burn_manager.cc @@ -57,7 +57,7 @@ void ReadFile(const FilePath& path, void CreateFileStream( const FilePath& file_path, base::Callback<void(net::FileStream* file_stream)> callback) { - scoped_ptr<net::FileStream> file_stream(new net::FileStream); + scoped_ptr<net::FileStream> file_stream(new net::FileStream(NULL)); // TODO(tbarzic): Save temp image file to temp folder instead of Downloads // once extracting image directly to removalbe device is implemented if (file_stream->Open(file_path, base::PLATFORM_FILE_OPEN_ALWAYS | diff --git a/chrome/browser/net/passive_log_collector.cc b/chrome/browser/net/passive_log_collector.cc index 9ca4b63..5006bdb 100644 --- a/chrome/browser/net/passive_log_collector.cc +++ b/chrome/browser/net/passive_log_collector.cc @@ -87,6 +87,8 @@ PassiveLogCollector::PassiveLogCollector() &cert_verifier_job_tracker_; trackers_[net::NetLog::SOURCE_HTTP_PIPELINED_CONNECTION] = &http_pipelined_connection_tracker_; + trackers_[net::NetLog::SOURCE_FILESTREAM] = + &file_stream_tracker_; // Make sure our mapping is up-to-date. for (size_t i = 0; i < arraysize(trackers_); ++i) DCHECK(trackers_[i]) << "Unhandled SourceType: " << i; @@ -844,3 +846,30 @@ PassiveLogCollector::HttpPipelinedConnectionTracker::DoAddEntry( } return ACTION_NONE; } + +//---------------------------------------------------------------------------- +// FileStreamTracker +//---------------------------------------------------------------------------- + +const size_t +PassiveLogCollector::FileStreamTracker::kMaxNumSources = 100; + +const size_t +PassiveLogCollector::FileStreamTracker::kMaxGraveyardSize = 25; + +PassiveLogCollector:: + FileStreamTracker::FileStreamTracker() + : SourceTracker(kMaxNumSources, kMaxGraveyardSize, NULL) { +} + +PassiveLogCollector::SourceTracker::Action +PassiveLogCollector::FileStreamTracker::DoAddEntry( + const ChromeNetLog::Entry& entry, + SourceInfo* out_info) { + AddEntryToSourceInfo(entry, out_info); + if (entry.type == net::NetLog::TYPE_FILE_STREAM_ALIVE && + entry.phase == net::NetLog::PHASE_END) { + return ACTION_MOVE_TO_GRAVEYARD; + } + return ACTION_NONE; +} diff --git a/chrome/browser/net/passive_log_collector.h b/chrome/browser/net/passive_log_collector.h index 2cb9ab4..c3b8da5 100644 --- a/chrome/browser/net/passive_log_collector.h +++ b/chrome/browser/net/passive_log_collector.h @@ -446,6 +446,21 @@ class PassiveLogCollector : public ChromeNetLog::ThreadSafeObserverImpl { DISALLOW_COPY_AND_ASSIGN(HttpPipelinedConnectionTracker); }; + // Tracks the log entries for the last seen SOURCE_FILESTREAM. + class FileStreamTracker : public SourceTracker { + public: + static const size_t kMaxNumSources; + static const size_t kMaxGraveyardSize; + + FileStreamTracker(); + + private: + virtual Action DoAddEntry(const ChromeNetLog::Entry& entry, + SourceInfo* out_info) OVERRIDE; + + DISALLOW_COPY_AND_ASSIGN(FileStreamTracker); + }; + PassiveLogCollector(); virtual ~PassiveLogCollector(); @@ -492,6 +507,7 @@ class PassiveLogCollector : public ChromeNetLog::ThreadSafeObserverImpl { UDPSocketTracker udp_socket_tracker_; CertVerifierJobTracker cert_verifier_job_tracker_; HttpPipelinedConnectionTracker http_pipelined_connection_tracker_; + FileStreamTracker file_stream_tracker_; // This array maps each NetLog::SourceType to one of the tracker instances // defined above. Use of this array avoid duplicating the list of trackers diff --git a/chrome/browser/resources/net_internals/events_view.css b/chrome/browser/resources/net_internals/events_view.css index 3b0c7bb..58c32ea 100644 --- a/chrome/browser/resources/net_internals/events_view.css +++ b/chrome/browser/resources/net_internals/events_view.css @@ -97,6 +97,10 @@ color: green; } +#events-view-source-list-tbody .source_FILESTREAM { + color: #700070; +} + #events-view-source-list-tbody .source_NONE { color: red; } diff --git a/chrome/browser/resources/net_internals/source_entry.js b/chrome/browser/resources/net_internals/source_entry.js index 389369b..c24f27b 100644 --- a/chrome/browser/resources/net_internals/source_entry.js +++ b/chrome/browser/resources/net_internals/source_entry.js @@ -132,6 +132,9 @@ var SourceEntry = (function() { case LogSourceType.DNS_TRANSACTION: this.description_ = e.params.hostname; break; + case LogSourceType.FILESTREAM: + this.description_ = e.params.file_name; + break; } if (this.description_ == undefined) @@ -156,6 +159,11 @@ var SourceEntry = (function() { getStartEntry_: function() { if (this.entries_.length < 1) return undefined; + if (this.entries_[0].source.type == LogSourceType.FILESTREAM) { + var e = this.findLogEntryByType_(LogEventType.FILE_STREAM_OPEN); + if (e != undefined) + return e; + } if (this.entries_.length >= 2) { if (this.entries_[0].type == LogEventType.REQUEST_ALIVE || this.entries_[0].type == LogEventType.SOCKET_POOL_CONNECT_JOB || @@ -166,6 +174,19 @@ var SourceEntry = (function() { return this.entries_[0]; }, + /** + * Returns the first entry with the specified type, or undefined if not + * found. + */ + findLogEntryByType_: function(type) { + for (var i = 0; i < this.entries_.length; ++i) { + if (this.entries_[i].type == type) { + return this.entries_[i]; + } + } + return undefined; + }, + getLogEntries: function() { return this.entries_; }, diff --git a/chrome/browser/safe_browsing/bloom_filter.cc b/chrome/browser/safe_browsing/bloom_filter.cc index b734009..c21c1c0 100644 --- a/chrome/browser/safe_browsing/bloom_filter.cc +++ b/chrome/browser/safe_browsing/bloom_filter.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -88,7 +88,7 @@ bool BloomFilter::Exists(SBPrefix hash) const { // static. BloomFilter* BloomFilter::LoadFile(const FilePath& filter_name) { - net::FileStream filter; + net::FileStream filter(NULL); if (filter.Open(filter_name, base::PLATFORM_FILE_OPEN | @@ -154,7 +154,7 @@ BloomFilter* BloomFilter::LoadFile(const FilePath& filter_name) { } bool BloomFilter::WriteFile(const FilePath& filter_name) const { - net::FileStream filter; + net::FileStream filter(NULL); if (filter.Open(filter_name, base::PLATFORM_FILE_WRITE | diff --git a/chrome/browser/sessions/session_backend.cc b/chrome/browser/sessions/session_backend.cc index 916f04a..f9d2b8c 100644 --- a/chrome/browser/sessions/session_backend.cc +++ b/chrome/browser/sessions/session_backend.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -45,7 +45,7 @@ class SessionFileReader { buffer_(SessionBackend::kFileReadBufferSize, 0), buffer_position_(0), available_count_(0) { - file_.reset(new net::FileStream()); + file_.reset(new net::FileStream(NULL)); if (file_util::PathExists(path)) file_->Open(path, base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ); } @@ -363,7 +363,7 @@ void SessionBackend::ResetFile() { net::FileStream* SessionBackend::OpenAndWriteHeader(const FilePath& path) { DCHECK(!path.empty()); - scoped_ptr<net::FileStream> file(new net::FileStream()); + scoped_ptr<net::FileStream> file(new net::FileStream(NULL)); if (file->Open(path, base::PLATFORM_FILE_CREATE_ALWAYS | base::PLATFORM_FILE_WRITE | base::PLATFORM_FILE_EXCLUSIVE_WRITE | base::PLATFORM_FILE_EXCLUSIVE_READ) != net::OK) diff --git a/chrome/browser/themes/browser_theme_pack.cc b/chrome/browser/themes/browser_theme_pack.cc index c35bee5..28c5db2 100644 --- a/chrome/browser/themes/browser_theme_pack.cc +++ b/chrome/browser/themes/browser_theme_pack.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -286,7 +286,7 @@ const int kPreloadIDs[] = { // Returns a piece of memory with the contents of the file |path|. RefCountedMemory* ReadFileData(const FilePath& path) { if (!path.empty()) { - net::FileStream file; + net::FileStream file(NULL); int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ; if (file.Open(path, flags) == net::OK) { int64 avail = file.Available(); |