OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | |
stuartmorgan
2015/05/19 17:39:36
Remove the (c)
Elly Fong-Jones
2015/05/20 22:02:26
Done.
| |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "ios/crnet/crnet_net_log.h" | |
6 | |
7 #include "base/files/file_path.h" | |
8 #include "base/files/file_util.h" | |
9 #include "base/files/scoped_file.h" | |
10 #include "base/values.h" | |
11 #include "net/log/net_log.h" | |
12 #include "net/log/net_log_util.h" | |
13 #include "net/log/write_to_file_net_log_observer.h" | |
14 | |
15 CrNetNetLog::CrNetNetLog() { } | |
16 CrNetNetLog::~CrNetNetLog() { } | |
17 | |
18 bool CrNetNetLog::Start(const base::FilePath& log_file, | |
19 CrNetNetLog::Mode mode) { | |
20 DCHECK(thread_checker_.CalledOnValidThread()); | |
21 base::FilePath temp_dir; | |
22 if (!base::GetTempDir(&temp_dir)) | |
23 return false; | |
24 | |
25 base::FilePath full_path = temp_dir.Append(log_file); | |
26 base::ScopedFILE file(base::OpenFile(full_path, "w")); | |
27 if (!file) | |
28 return false; | |
29 | |
30 scoped_ptr<base::Value> constants(net::GetNetConstants().Pass()); | |
31 | |
32 net::NetLogCaptureMode capture_mode = mode == LOG_ALL_BYTES ? | |
33 net::NetLogCaptureMode::IncludeSocketBytes() : | |
34 net::NetLogCaptureMode::Default(); | |
35 write_to_file_observer_.reset(new net::WriteToFileNetLogObserver()); | |
36 write_to_file_observer_->set_capture_mode(capture_mode); | |
37 write_to_file_observer_->StartObserving(this, file.Pass(), constants.get(), | |
38 nullptr); | |
39 return true; | |
40 } | |
41 | |
42 void CrNetNetLog::Stop() { | |
43 DCHECK(thread_checker_.CalledOnValidThread()); | |
44 write_to_file_observer_->StopObserving(nullptr); | |
45 write_to_file_observer_.reset(); | |
46 } | |
OLD | NEW |