Reland of Adding total available size of heap in v8 isolate memory dump provider.
[chromium-blink-merge.git] / ios / crnet / crnet_net_log.cc
blob4ad3d3057d7317d68f2f90f3f7bbb6c2b7dc090f
1 // Copyright 2015 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 "ios/crnet/crnet_net_log.h"
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"
15 CrNetNetLog::CrNetNetLog() { }
16 CrNetNetLog::~CrNetNetLog() { }
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;
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;
30 scoped_ptr<base::Value> constants(net::GetNetConstants().Pass());
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;
42 void CrNetNetLog::Stop() {
43 DCHECK(thread_checker_.CalledOnValidThread());
44 write_to_file_observer_->StopObserving(nullptr);
45 write_to_file_observer_.reset();