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

Unified Diff: net/log/net_log_logger.cc

Issue 1084533002: Rename NetLogLogger and CapturingNetLog (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename NetLogLogger and CapturingNetLog(removed compiler error for chromeOS) Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/log/net_log_logger.h ('k') | net/log/net_log_logger_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/log/net_log_logger.cc
diff --git a/net/log/net_log_logger.cc b/net/log/net_log_logger.cc
deleted file mode 100644
index 4a2b475d95aa65c7b790e4df8704897944c67ef8..0000000000000000000000000000000000000000
--- a/net/log/net_log_logger.cc
+++ /dev/null
@@ -1,99 +0,0 @@
-// Copyright 2013 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.
-
-#include "net/log/net_log_logger.h"
-
-#include <stdio.h>
-
-#include <set>
-
-#include "base/json/json_writer.h"
-#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/values.h"
-#include "net/log/net_log_util.h"
-#include "net/url_request/url_request_context.h"
-
-namespace net {
-
-NetLogLogger::NetLogLogger()
- : log_level_(NetLog::LOG_STRIP_PRIVATE_DATA), added_events_(false) {
-}
-
-NetLogLogger::~NetLogLogger() {
-}
-
-void NetLogLogger::set_log_level(net::NetLog::LogLevel log_level) {
- DCHECK(!net_log());
- log_level_ = log_level;
-}
-
-void NetLogLogger::StartObserving(net::NetLog* net_log,
- base::ScopedFILE file,
- base::Value* constants,
- net::URLRequestContext* url_request_context) {
- DCHECK(file.get());
- file_ = file.Pass();
- added_events_ = false;
-
- // Write constants to the output file. This allows loading files that have
- // different source and event types, as they may be added and removed
- // between Chrome versions.
- std::string json;
- if (constants) {
- base::JSONWriter::Write(constants, &json);
- } else {
- scoped_ptr<base::DictionaryValue> scoped_constants(GetNetConstants());
- base::JSONWriter::Write(scoped_constants.get(), &json);
- }
- fprintf(file_.get(), "{\"constants\": %s,\n", json.c_str());
-
- // Start events array. It's closed in StopObserving().
- fprintf(file_.get(), "\"events\": [\n");
-
- // Add events for in progress requests if a context is given.
- if (url_request_context) {
- DCHECK(url_request_context->CalledOnValidThread());
-
- std::set<URLRequestContext*> contexts;
- contexts.insert(url_request_context);
- CreateNetLogEntriesForActiveObjects(contexts, this);
- }
-
- net_log->DeprecatedAddObserver(this, log_level_);
-}
-
-void NetLogLogger::StopObserving(net::URLRequestContext* url_request_context) {
- net_log()->DeprecatedRemoveObserver(this);
-
- // End events array.
- fprintf(file_.get(), "]");
-
- // Write state of the URLRequestContext when logging stopped.
- if (url_request_context) {
- DCHECK(url_request_context->CalledOnValidThread());
-
- std::string json;
- scoped_ptr<base::DictionaryValue> net_info =
- GetNetInfo(url_request_context, NET_INFO_ALL_SOURCES);
- base::JSONWriter::Write(net_info.get(), &json);
- fprintf(file_.get(), ",\"tabInfo\": %s\n", json.c_str());
- }
- fprintf(file_.get(), "}");
-
- file_.reset();
-}
-
-void NetLogLogger::OnAddEntry(const net::NetLog::Entry& entry) {
- // Add a comma and newline for every event but the first. Newlines are needed
- // so can load partial log files by just ignoring the last line. For this to
- // work, lines cannot be pretty printed.
- scoped_ptr<base::Value> value(entry.ToValue());
- std::string json;
- base::JSONWriter::Write(value.get(), &json);
- fprintf(file_.get(), "%s%s", (added_events_ ? ",\n" : ""), json.c_str());
- added_events_ = true;
-}
-
-} // namespace net
« no previous file with comments | « net/log/net_log_logger.h ('k') | net/log/net_log_logger_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698