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.
|
|
|
|
|
2019-06-19 20:56:58 +00:00
|
|
|
#ifndef SHELL_BROWSER_API_ATOM_API_NET_LOG_H_
|
|
|
|
#define SHELL_BROWSER_API_ATOM_API_NET_LOG_H_
|
2018-06-19 01:45:58 +00:00
|
|
|
|
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 "base/callback.h"
|
2019-05-23 22:31:38 +00:00
|
|
|
#include "base/optional.h"
|
2018-10-04 18:08:56 +00:00
|
|
|
#include "base/values.h"
|
|
|
|
#include "native_mate/handle.h"
|
2019-05-23 22:31:38 +00:00
|
|
|
#include "services/network/public/mojom/net_log.mojom.h"
|
2019-06-19 20:46:59 +00:00
|
|
|
#include "shell/browser/api/trackable_object.h"
|
|
|
|
#include "shell/common/promise_util.h"
|
2018-06-19 01:45:58 +00:00
|
|
|
|
2019-06-19 21:23:04 +00:00
|
|
|
namespace electron {
|
2018-06-19 01:45:58 +00:00
|
|
|
|
2018-10-04 18:08:56 +00:00
|
|
|
class AtomBrowserContext;
|
|
|
|
|
2018-06-19 01:45:58 +00:00
|
|
|
namespace api {
|
|
|
|
|
2019-05-23 22:31:38 +00:00
|
|
|
class NetLog : public mate::TrackableObject<NetLog> {
|
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);
|
|
|
|
|
2019-07-25 23:06:39 +00:00
|
|
|
v8::Local<v8::Promise> StartLogging(base::FilePath log_path,
|
|
|
|
mate::Arguments* args);
|
2019-02-19 10:48:27 +00:00
|
|
|
v8::Local<v8::Promise> StopLogging(mate::Arguments* args);
|
2019-05-23 22:31:38 +00:00
|
|
|
bool IsCurrentlyLogging() const;
|
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;
|
|
|
|
|
2019-05-23 22:31:38 +00:00
|
|
|
void OnConnectionError();
|
|
|
|
|
2019-05-24 17:54:32 +00:00
|
|
|
void StartNetLogAfterCreateFile(net::NetLogCaptureMode capture_mode,
|
|
|
|
uint64_t max_file_size,
|
|
|
|
base::Value custom_constants,
|
|
|
|
base::File output_file);
|
2019-05-23 22:31:38 +00:00
|
|
|
void NetLogStarted(int32_t error);
|
2018-10-04 18:08:56 +00:00
|
|
|
|
2018-06-19 01:45:58 +00:00
|
|
|
private:
|
2018-10-04 18:08:56 +00:00
|
|
|
AtomBrowserContext* browser_context_;
|
2019-05-23 22:31:38 +00:00
|
|
|
|
|
|
|
network::mojom::NetLogExporterPtr net_log_exporter_;
|
|
|
|
|
2019-08-23 00:03:28 +00:00
|
|
|
base::Optional<util::Promise<void*>> pending_start_promise_;
|
2019-05-23 22:31:38 +00:00
|
|
|
|
|
|
|
scoped_refptr<base::TaskRunner> file_task_runner_;
|
|
|
|
|
|
|
|
base::WeakPtrFactory<NetLog> weak_ptr_factory_;
|
2018-06-19 01:45:58 +00:00
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(NetLog);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace api
|
|
|
|
|
2019-06-19 21:23:04 +00:00
|
|
|
} // namespace electron
|
2018-06-19 01:45:58 +00:00
|
|
|
|
2019-06-19 20:56:58 +00:00
|
|
|
#endif // SHELL_BROWSER_API_ATOM_API_NET_LOG_H_
|