Add signalSyncPoint to the WebGraphicsContext3D command buffer impls.
[chromium-blink-merge.git] / net / tools / gdig / file_net_log.cc
blob51cf78d60e0f8b8949c37f32a0dbace2e3b5e8b6
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
3 // found in the LICENSE file.
5 #include <stdio.h>
7 #include "base/json/json_string_value_serializer.h"
8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/values.h"
11 #include "net/tools/gdig/file_net_log.h"
13 namespace net {
15 FileNetLog::FileNetLog(FILE* destination, LogLevel level)
16 : log_level_(level),
17 destination_(destination) {
18 DCHECK(destination != NULL);
19 // Without calling GetNext() once here, the first GetNext will return 0
20 // that is not a valid id.
21 sequence_number_.GetNext();
24 FileNetLog::~FileNetLog() {
27 void FileNetLog::OnAddEntry(const net::NetLog::Entry& entry) {
28 // Only BoundNetLogs without a NetLog should have an invalid source.
29 DCHECK(entry.source().IsValid());
31 const char* source = SourceTypeToString(entry.source().type);
32 const char* type = EventTypeToString(entry.type());
34 scoped_ptr<Value> param_value(entry.ParametersToValue());
35 std::string params;
36 if (param_value.get() != NULL) {
37 JSONStringValueSerializer serializer(&params);
38 bool ret = serializer.Serialize(*param_value);
39 DCHECK(ret);
41 base::Time now = base::Time::NowFromSystemTime();
42 base::AutoLock lock(lock_);
43 if (first_event_time_.is_null()) {
44 first_event_time_ = now;
46 base::TimeDelta elapsed_time = now - first_event_time_;
47 fprintf(destination_ , "%u\t%u\t%s\t%s\t%s\n",
48 static_cast<unsigned>(elapsed_time.InMilliseconds()),
49 entry.source().id, source, type, params.c_str());
52 uint32 FileNetLog::NextID() {
53 return sequence_number_.GetNext();
56 NetLog::LogLevel FileNetLog::GetLogLevel() const {
57 return log_level_;
60 void FileNetLog::AddThreadSafeObserver(
61 NetLog::ThreadSafeObserver* observer,
62 NetLog::LogLevel log_level) {
63 NOTIMPLEMENTED() << "Not currently used by gdig.";
66 void FileNetLog::SetObserverLogLevel(ThreadSafeObserver* observer,
67 LogLevel log_level) {
68 NOTIMPLEMENTED() << "Not currently used by gdig.";
71 void FileNetLog::RemoveThreadSafeObserver(
72 NetLog::ThreadSafeObserver* observer) {
73 NOTIMPLEMENTED() << "Not currently used by gdig.";
76 } // namespace net