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

Side by Side Diff: chrome/browser/net/net_log_logger.cc

Issue 11828036: First cut at UI for saving net_logs data into a temporary file on (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 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
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/browser/net/net_log_logger.h" 5 #include "chrome/browser/net/net_log_logger.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 25 matching lines...) Expand all
36 } 36 }
37 } 37 }
38 38
39 NetLogLogger::~NetLogLogger() { 39 NetLogLogger::~NetLogLogger() {
40 } 40 }
41 41
42 void NetLogLogger::StartObserving(net::NetLog* net_log) { 42 void NetLogLogger::StartObserving(net::NetLog* net_log) {
43 net_log->AddThreadSafeObserver(this, net::NetLog::LOG_ALL_BUT_BYTES); 43 net_log->AddThreadSafeObserver(this, net::NetLog::LOG_ALL_BUT_BYTES);
44 } 44 }
45 45
46 void NetLogLogger::StopObserving() {
47 net_log()->RemoveThreadSafeObserver(this);
48 }
49
46 void NetLogLogger::OnAddEntry(const net::NetLog::Entry& entry) { 50 void NetLogLogger::OnAddEntry(const net::NetLog::Entry& entry) {
47 scoped_ptr<Value> value(entry.ToValue()); 51 scoped_ptr<Value> value(entry.ToValue());
48 // Don't pretty print, so each JSON value occupies a single line, with no 52 // Don't pretty print, so each JSON value occupies a single line, with no
49 // breaks (Line breaks in any text field will be escaped). Using strings 53 // breaks (Line breaks in any text field will be escaped). Using strings
50 // instead of integer identifiers allows logs from older versions to be 54 // instead of integer identifiers allows logs from older versions to be
51 // loaded, though a little extra parsing has to be done when loading a log. 55 // loaded, though a little extra parsing has to be done when loading a log.
52 std::string json; 56 std::string json;
53 base::JSONWriter::Write(value.get(), &json); 57 base::JSONWriter::Write(value.get(), &json);
54 if (!file_.get()) { 58 if (!file_.get()) {
55 VLOG(1) << json; 59 VLOG(1) << json;
56 } else { 60 } else {
57 fprintf(file_.get(), "%s,\n", json.c_str()); 61 fprintf(file_.get(), "%s,\n", json.c_str());
58 } 62 }
59 } 63 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698