| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2010 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. | |
| 4 | |
| 5 #ifndef NET_BASE_FORWARDING_NET_LOG_H_ | |
| 6 #define NET_BASE_FORWARDING_NET_LOG_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include "base/basictypes.h" | |
| 10 #include "net/base/net_log.h" | |
| 11 | |
| 12 class MessageLoop; | |
| 13 | |
| 14 namespace net { | |
| 15 | |
| 16 // ForwardingNetLog is a wrapper that can be called on any thread, and will | |
| 17 // forward any calls to NetLog::AddEntry() over to |impl| on the specified | |
| 18 // message loop. | |
| 19 // | |
| 20 // This allows using a non-threadsafe NetLog implementation from another | |
| 21 // thread. | |
| 22 // | |
| 23 // TODO(eroman): Explore making NetLog threadsafe and obviating the need | |
| 24 // for this class. | |
| 25 class ForwardingNetLog : public NetLog { | |
| 26 public: | |
| 27 // Both |impl| and |loop| must outlive the lifetime of this instance. | |
| 28 // |impl| will be operated only from |loop|. | |
| 29 ForwardingNetLog(NetLog* impl, MessageLoop* loop); | |
| 30 | |
| 31 // On destruction any outstanding call to AddEntry() which didn't make | |
| 32 // it to |loop| yet will be cancelled. | |
| 33 ~ForwardingNetLog(); | |
| 34 | |
| 35 // NetLog methods: | |
| 36 virtual void AddEntry(EventType type, | |
| 37 const base::TimeTicks& time, | |
| 38 const Source& source, | |
| 39 EventPhase phase, | |
| 40 EventParameters* params); | |
| 41 virtual uint32 NextID(); | |
| 42 virtual LogLevel GetLogLevel() const; | |
| 43 | |
| 44 private: | |
| 45 class Core; | |
| 46 scoped_refptr<Core> core_; | |
| 47 | |
| 48 DISALLOW_COPY_AND_ASSIGN(ForwardingNetLog); | |
| 49 }; | |
| 50 | |
| 51 } // namespace net | |
| 52 | |
| 53 #endif // NET_BASE_FORWARDING_NET_LOG_H_ | |
| 54 | |
| OLD | NEW |