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.
|
|
|
|
|
2020-02-04 20:19:40 +00:00
|
|
|
#ifndef SHELL_BROWSER_API_ELECTRON_API_NET_LOG_H_
|
|
|
|
#define SHELL_BROWSER_API_ELECTRON_API_NET_LOG_H_
|
2018-06-19 01:45:58 +00:00
|
|
|
|
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"
|
2019-10-25 13:03:28 +00:00
|
|
|
#include "gin/handle.h"
|
2020-03-18 23:46:05 +00:00
|
|
|
#include "gin/wrappable.h"
|
2019-05-23 22:31:38 +00:00
|
|
|
#include "services/network/public/mojom/net_log.mojom.h"
|
2019-11-01 06:10:32 +00:00
|
|
|
#include "shell/common/gin_helper/promise.h"
|
2020-03-18 23:46:05 +00:00
|
|
|
|
|
|
|
namespace gin {
|
|
|
|
class Arguments;
|
|
|
|
}
|
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
|
|
|
|
2020-02-04 20:19:40 +00:00
|
|
|
class ElectronBrowserContext;
|
2018-10-04 18:08:56 +00:00
|
|
|
|
2018-06-19 01:45:58 +00:00
|
|
|
namespace api {
|
|
|
|
|
2020-03-18 23:46:05 +00:00
|
|
|
class NetLog : public gin::Wrappable<NetLog> {
|
2018-06-19 01:45:58 +00:00
|
|
|
public:
|
2019-10-25 13:03:28 +00:00
|
|
|
static gin::Handle<NetLog> Create(v8::Isolate* isolate,
|
2020-02-04 20:19:40 +00:00
|
|
|
ElectronBrowserContext* browser_context);
|
2018-06-19 01:45:58 +00:00
|
|
|
|
2019-07-25 23:06:39 +00:00
|
|
|
v8::Local<v8::Promise> StartLogging(base::FilePath log_path,
|
2020-03-18 23:46:05 +00:00
|
|
|
gin::Arguments* args);
|
|
|
|
v8::Local<v8::Promise> StopLogging(gin::Arguments* args);
|
2019-05-23 22:31:38 +00:00
|
|
|
bool IsCurrentlyLogging() const;
|
2018-06-19 01:45:58 +00:00
|
|
|
|
2020-03-18 23:46:05 +00:00
|
|
|
// gin::Wrappable
|
|
|
|
static gin::WrapperInfo kWrapperInfo;
|
|
|
|
gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
|
|
|
|
v8::Isolate* isolate) override;
|
|
|
|
const char* GetTypeName() override;
|
|
|
|
|
2018-06-19 01:45:58 +00:00
|
|
|
protected:
|
2020-02-04 20:19:40 +00:00
|
|
|
explicit NetLog(v8::Isolate* isolate,
|
|
|
|
ElectronBrowserContext* 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:
|
2020-02-04 20:19:40 +00:00
|
|
|
ElectronBrowserContext* browser_context_;
|
2019-05-23 22:31:38 +00:00
|
|
|
|
|
|
|
network::mojom::NetLogExporterPtr net_log_exporter_;
|
|
|
|
|
2019-11-01 06:10:32 +00:00
|
|
|
base::Optional<gin_helper::Promise<void>> pending_start_promise_;
|
2019-05-23 22:31:38 +00:00
|
|
|
|
|
|
|
scoped_refptr<base::TaskRunner> file_task_runner_;
|
|
|
|
|
2021-01-26 18:16:21 +00:00
|
|
|
base::WeakPtrFactory<NetLog> weak_ptr_factory_{this};
|
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
|
|
|
|
2020-02-04 20:19:40 +00:00
|
|
|
#endif // SHELL_BROWSER_API_ELECTRON_API_NET_LOG_H_
|