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

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

Issue 10399083: Make NetLog take in callbacks that return Values (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Fix merge error 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 "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 19 matching lines...) Expand all
30 } 30 }
31 } 31 }
32 32
33 NetLogLogger::~NetLogLogger() { 33 NetLogLogger::~NetLogLogger() {
34 } 34 }
35 35
36 void NetLogLogger::StartObserving(net::NetLog* net_log) { 36 void NetLogLogger::StartObserving(net::NetLog* net_log) {
37 net_log->AddThreadSafeObserver(this, net::NetLog::LOG_ALL_BUT_BYTES); 37 net_log->AddThreadSafeObserver(this, net::NetLog::LOG_ALL_BUT_BYTES);
38 } 38 }
39 39
40 void NetLogLogger::OnAddEntry(net::NetLog::EventType type, 40 void NetLogLogger::OnAddEntry(const net::NetLog::Entry& entry) {
41 const base::TimeTicks& time, 41 scoped_ptr<Value> value(entry.ToValue());
42 const net::NetLog::Source& source,
43 net::NetLog::EventPhase phase,
44 net::NetLog::EventParameters* params) {
45 scoped_ptr<Value> value(
46 net::NetLog::EntryToDictionaryValue(
47 type, time, source, phase, params, false));
48 // Don't pretty print, so each JSON value occupies a single line, with no 42 // 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 43 // breaks (Line breaks in any text field will be escaped). Using strings
50 // instead of integer identifiers allows logs from older versions to be 44 // 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. 45 // loaded, though a little extra parsing has to be done when loading a log.
52 std::string json; 46 std::string json;
53 base::JSONWriter::Write(value.get(), &json); 47 base::JSONWriter::Write(value.get(), &json);
54 if (!file_.get()) { 48 if (!file_.get()) {
55 VLOG(1) << json; 49 VLOG(1) << json;
56 } else { 50 } else {
57 fprintf(file_.get(), "%s,\n", json.c_str()); 51 fprintf(file_.get(), "%s,\n", json.c_str());
58 } 52 }
59 } 53 }
OLDNEW
« no previous file with comments | « chrome/browser/net/net_log_logger.h ('k') | chrome/browser/ui/webui/media/media_internals_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698