Check USB device path access when prompting users to select a device.
[chromium-blink-merge.git] / net / log / capturing_net_log_observer.h
blobd9faa06063c46076c6cb5ed8faf3b335a71e8379
1 // Copyright 2014 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 #ifndef NET_LOG_CAPTURING_NET_LOG_OBSERVER_H_
6 #define NET_LOG_CAPTURING_NET_LOG_OBSERVER_H_
8 #include <string>
9 #include <vector>
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "base/synchronization/lock.h"
14 #include "net/log/captured_net_log_entry.h"
15 #include "net/log/net_log.h"
17 namespace base {
18 class DictionaryValue;
19 class ListValue;
22 namespace net {
24 // CapturingNetLogObserver is an implementation of NetLog::ThreadSafeObserver
25 // that saves messages to a bounded buffer. It is intended for testing only,
26 // and is part of the net_test_support project.
27 class CapturingNetLogObserver : public NetLog::ThreadSafeObserver {
28 public:
29 CapturingNetLogObserver();
30 ~CapturingNetLogObserver() override;
32 // Returns the list of all entries in the log.
33 void GetEntries(CapturedNetLogEntry::List* entry_list) const;
35 // Fills |entry_list| with all entries in the log from the specified Source.
36 void GetEntriesForSource(NetLog::Source source,
37 CapturedNetLogEntry::List* entry_list) const;
39 // Returns number of entries in the log.
40 size_t GetSize() const;
42 void Clear();
44 private:
45 // ThreadSafeObserver implementation:
46 void OnAddEntry(const NetLog::Entry& entry) override;
48 // Needs to be "mutable" so can use it in GetEntries().
49 mutable base::Lock lock_;
51 CapturedNetLogEntry::List captured_entries_;
53 DISALLOW_COPY_AND_ASSIGN(CapturingNetLogObserver);
56 } // namespace net
58 #endif // NET_LOG_CAPTURING_NET_LOG_OBSERVER_H_