2018-06-19 01:45:58 +00:00
|
|
|
// Copyright (c) 2018 GitHub, Inc.
|
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#ifndef ATOM_BROWSER_API_ATOM_API_NET_LOG_H_
|
|
|
|
#define ATOM_BROWSER_API_ATOM_API_NET_LOG_H_
|
|
|
|
|
2018-10-04 18:08:56 +00:00
|
|
|
#include <list>
|
|
|
|
#include <memory>
|
2018-06-19 01:45:58 +00:00
|
|
|
#include <string>
|
2018-10-04 18:08:56 +00:00
|
|
|
|
|
|
|
#include "atom/browser/api/trackable_object.h"
|
2019-02-19 10:48:27 +00:00
|
|
|
#include "atom/common/promise_util.h"
|
2018-10-04 18:08:56 +00:00
|
|
|
#include "base/callback.h"
|
|
|
|
#include "base/values.h"
|
|
|
|
#include "components/net_log/net_export_file_writer.h"
|
|
|
|
#include "native_mate/handle.h"
|
2018-06-19 01:45:58 +00:00
|
|
|
|
|
|
|
namespace atom {
|
|
|
|
|
2018-10-04 18:08:56 +00:00
|
|
|
class AtomBrowserContext;
|
|
|
|
|
2018-06-19 01:45:58 +00:00
|
|
|
namespace api {
|
|
|
|
|
2018-10-04 18:08:56 +00:00
|
|
|
class NetLog : public mate::TrackableObject<NetLog>,
|
|
|
|
public net_log::NetExportFileWriter::StateObserver {
|
2018-06-19 01:45:58 +00:00
|
|
|
public:
|
2018-10-04 18:08:56 +00:00
|
|
|
static mate::Handle<NetLog> Create(v8::Isolate* isolate,
|
|
|
|
AtomBrowserContext* browser_context);
|
2018-06-19 01:45:58 +00:00
|
|
|
|
|
|
|
static void BuildPrototype(v8::Isolate* isolate,
|
|
|
|
v8::Local<v8::FunctionTemplate> prototype);
|
|
|
|
|
|
|
|
void StartLogging(mate::Arguments* args);
|
2018-10-04 18:08:56 +00:00
|
|
|
std::string GetLoggingState() const;
|
|
|
|
bool IsCurrentlyLogging() const;
|
|
|
|
std::string GetCurrentlyLoggingPath() const;
|
2019-02-19 10:48:27 +00:00
|
|
|
v8::Local<v8::Promise> StopLogging(mate::Arguments* args);
|
2018-06-19 01:45:58 +00:00
|
|
|
|
|
|
|
protected:
|
2018-10-04 18:08:56 +00:00
|
|
|
explicit NetLog(v8::Isolate* isolate, AtomBrowserContext* browser_context);
|
2018-06-19 01:45:58 +00:00
|
|
|
~NetLog() override;
|
|
|
|
|
2018-10-04 18:08:56 +00:00
|
|
|
// net_log::NetExportFileWriter::StateObserver implementation
|
|
|
|
void OnNewState(const base::DictionaryValue& state) override;
|
|
|
|
|
2018-06-19 01:45:58 +00:00
|
|
|
private:
|
2018-10-04 18:08:56 +00:00
|
|
|
AtomBrowserContext* browser_context_;
|
|
|
|
net_log::NetExportFileWriter* net_log_writer_;
|
2019-02-21 12:32:44 +00:00
|
|
|
std::list<atom::util::Promise> stop_callback_queue_;
|
2018-10-04 18:08:56 +00:00
|
|
|
std::unique_ptr<base::DictionaryValue> net_log_state_;
|
2018-06-19 01:45:58 +00:00
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(NetLog);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace api
|
|
|
|
|
|
|
|
} // namespace atom
|
|
|
|
|
|
|
|
#endif // ATOM_BROWSER_API_ATOM_API_NET_LOG_H_
|