Commit 25d9ec2b authored by Maks Orlovich's avatar Maks Orlovich Committed by Commit Bot

FileNetLogObserver: use uint64_t and not size_t for size limits

This is so that exporting of this functionality over mojo can accurately
express the underlying type and the kNoLimit constant. (Which doesn't
seem doable with size_t since its size, and therefore value of its max,
differs on different platforms).

Bug: 767450
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I741bfe1c942e5ee7752f346932a26e861cefb0c8
Reviewed-on: https://chromium-review.googlesource.com/1027905Reviewed-by: default avatarEric Roman <eroman@chromium.org>
Commit-Queue: Maks Orlovich <morlovich@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553891}
parent 752b6070
...@@ -154,7 +154,7 @@ class NetExportMessageHandler ...@@ -154,7 +154,7 @@ class NetExportMessageHandler
// the save dialog. Their values are only valid while the save dialog is open // the save dialog. Their values are only valid while the save dialog is open
// on the desktop UI. // on the desktop UI.
net::NetLogCaptureMode capture_mode_; net::NetLogCaptureMode capture_mode_;
size_t max_log_file_size_; uint64_t max_log_file_size_;
scoped_refptr<ui::SelectFileDialog> select_file_dialog_; scoped_refptr<ui::SelectFileDialog> select_file_dialog_;
......
...@@ -164,7 +164,7 @@ void NetExportFileWriter::Initialize( ...@@ -164,7 +164,7 @@ void NetExportFileWriter::Initialize(
void NetExportFileWriter::StartNetLog( void NetExportFileWriter::StartNetLog(
const base::FilePath& log_path, const base::FilePath& log_path,
net::NetLogCaptureMode capture_mode, net::NetLogCaptureMode capture_mode,
size_t max_file_size, uint64_t max_file_size,
const base::CommandLine::StringType& command_line_string, const base::CommandLine::StringType& command_line_string,
const std::string& channel_string, const std::string& channel_string,
const URLRequestContextGetterList& context_getters) { const URLRequestContextGetterList& context_getters) {
......
...@@ -56,7 +56,7 @@ class ChromeNetLog; ...@@ -56,7 +56,7 @@ class ChromeNetLog;
class NetExportFileWriter { class NetExportFileWriter {
public: public:
// Special value meaning "can use an unlimited number of bytes". // Special value meaning "can use an unlimited number of bytes".
static constexpr size_t kNoLimit = net::FileNetLogObserver::kNoLimit; static constexpr uint64_t kNoLimit = net::FileNetLogObserver::kNoLimit;
// The observer interface to be implemented by code that wishes to be notified // The observer interface to be implemented by code that wishes to be notified
// of NetExportFileWriter's state changes. // of NetExportFileWriter's state changes.
...@@ -109,7 +109,7 @@ class NetExportFileWriter { ...@@ -109,7 +109,7 @@ class NetExportFileWriter {
// thread. // thread.
void StartNetLog(const base::FilePath& log_path, void StartNetLog(const base::FilePath& log_path,
net::NetLogCaptureMode capture_mode, net::NetLogCaptureMode capture_mode,
size_t max_file_size, uint64_t max_file_size,
const base::CommandLine::StringType& command_line_string, const base::CommandLine::StringType& command_line_string,
const std::string& channel_string, const std::string& channel_string,
const URLRequestContextGetterList& context_getters); const URLRequestContextGetterList& context_getters);
......
...@@ -148,7 +148,7 @@ void NetExportMessageHandler::OnStartNetLog(const base::ListValue* list) { ...@@ -148,7 +148,7 @@ void NetExportMessageHandler::OnStartNetLog(const base::ListValue* list) {
} }
// Determine the max file size. // Determine the max file size.
size_t max_log_file_size = net_log::NetExportFileWriter::kNoLimit; uint64_t max_log_file_size = net_log::NetExportFileWriter::kNoLimit;
if (params.size() > 1 && params[1].is_int() && params[1].GetInt() > 0) { if (params.size() > 1 && params[1].is_int() && params[1].GetInt() > 0) {
max_log_file_size = params[1].GetInt(); max_log_file_size = params[1].GetInt();
} }
......
...@@ -137,7 +137,7 @@ class FileNetLogObserver::WriteQueue ...@@ -137,7 +137,7 @@ class FileNetLogObserver::WriteQueue
// |memory_max| indicates the maximum amount of memory that the virtual write // |memory_max| indicates the maximum amount of memory that the virtual write
// queue can use. If |memory_| exceeds |memory_max_|, the |queue_| of events // queue can use. If |memory_| exceeds |memory_max_|, the |queue_| of events
// is overwritten. // is overwritten.
explicit WriteQueue(size_t memory_max); explicit WriteQueue(uint64_t memory_max);
// Adds |event| to |queue_|. Also manages the size of |memory_|; if it // Adds |event| to |queue_|. Also manages the size of |memory_|; if it
// exceeds |memory_max_|, then old events are dropped from |queue_| without // exceeds |memory_max_|, then old events are dropped from |queue_| without
...@@ -168,11 +168,11 @@ class FileNetLogObserver::WriteQueue ...@@ -168,11 +168,11 @@ class FileNetLogObserver::WriteQueue
// runner's local queue is swapped with the shared write queue. // runner's local queue is swapped with the shared write queue.
// //
// |lock_| must be acquired to read or write to this. // |lock_| must be acquired to read or write to this.
size_t memory_; uint64_t memory_;
// Indicates the maximum amount of memory that the |queue_| is allowed to // Indicates the maximum amount of memory that the |queue_| is allowed to
// use. // use.
const size_t memory_max_; const uint64_t memory_max_;
// Protects access to |queue_| and |memory_|. // Protects access to |queue_| and |memory_|.
// //
...@@ -199,7 +199,7 @@ class FileNetLogObserver::FileWriter { ...@@ -199,7 +199,7 @@ class FileNetLogObserver::FileWriter {
FileWriter(const base::FilePath& log_path, FileWriter(const base::FilePath& log_path,
const base::FilePath& inprogress_dir_path, const base::FilePath& inprogress_dir_path,
base::Optional<base::File> pre_existing_log_file, base::Optional<base::File> pre_existing_log_file,
size_t max_event_file_size, uint64_t max_event_file_size,
size_t total_num_event_files, size_t total_num_event_files,
scoped_refptr<base::SequencedTaskRunner> task_runner); scoped_refptr<base::SequencedTaskRunner> task_runner);
...@@ -302,7 +302,7 @@ class FileNetLogObserver::FileWriter { ...@@ -302,7 +302,7 @@ class FileNetLogObserver::FileWriter {
// The file may be !IsValid() if an error previously occurred opening the // The file may be !IsValid() if an error previously occurred opening the
// file, or logging has been stopped. // file, or logging has been stopped.
base::File current_event_file_; base::File current_event_file_;
size_t current_event_file_size_; uint64_t current_event_file_size_;
// Indicates the total number of netlog event files allowed. // Indicates the total number of netlog event files allowed.
// (The files GetConstantsFilePath() and GetClosingFilePath() do // (The files GetConstantsFilePath() and GetClosingFilePath() do
...@@ -315,7 +315,7 @@ class FileNetLogObserver::FileWriter { ...@@ -315,7 +315,7 @@ class FileNetLogObserver::FileWriter {
// Indicates the maximum size of each individual events file. May be kNoLimit // Indicates the maximum size of each individual events file. May be kNoLimit
// to indicate that it can grow arbitrarily large. // to indicate that it can grow arbitrarily large.
const size_t max_event_file_size_; const uint64_t max_event_file_size_;
// Whether any bytes were written for events. This is used to properly format // Whether any bytes were written for events. This is used to properly format
// JSON (events list shouldn't end with a comma). // JSON (events list shouldn't end with a comma).
...@@ -329,7 +329,7 @@ class FileNetLogObserver::FileWriter { ...@@ -329,7 +329,7 @@ class FileNetLogObserver::FileWriter {
std::unique_ptr<FileNetLogObserver> FileNetLogObserver::CreateBounded( std::unique_ptr<FileNetLogObserver> FileNetLogObserver::CreateBounded(
const base::FilePath& log_path, const base::FilePath& log_path,
size_t max_total_size, uint64_t max_total_size,
std::unique_ptr<base::Value> constants) { std::unique_ptr<base::Value> constants) {
return CreateInternal(log_path, SiblingInprogressDirectory(log_path), return CreateInternal(log_path, SiblingInprogressDirectory(log_path),
base::nullopt, max_total_size, kDefaultNumFiles, base::nullopt, max_total_size, kDefaultNumFiles,
...@@ -347,7 +347,7 @@ std::unique_ptr<FileNetLogObserver> ...@@ -347,7 +347,7 @@ std::unique_ptr<FileNetLogObserver>
FileNetLogObserver::CreateBoundedPreExisting( FileNetLogObserver::CreateBoundedPreExisting(
const base::FilePath& inprogress_dir_path, const base::FilePath& inprogress_dir_path,
base::File output_file, base::File output_file,
size_t max_total_size, uint64_t max_total_size,
std::unique_ptr<base::Value> constants) { std::unique_ptr<base::Value> constants) {
return CreateInternal(base::FilePath(), inprogress_dir_path, return CreateInternal(base::FilePath(), inprogress_dir_path,
base::make_optional<base::File>(std::move(output_file)), base::make_optional<base::File>(std::move(output_file)),
...@@ -421,7 +421,7 @@ void FileNetLogObserver::OnAddEntry(const NetLogEntry& entry) { ...@@ -421,7 +421,7 @@ void FileNetLogObserver::OnAddEntry(const NetLogEntry& entry) {
std::unique_ptr<FileNetLogObserver> FileNetLogObserver::CreateBoundedForTests( std::unique_ptr<FileNetLogObserver> FileNetLogObserver::CreateBoundedForTests(
const base::FilePath& log_path, const base::FilePath& log_path,
size_t max_total_size, uint64_t max_total_size,
size_t total_num_event_files, size_t total_num_event_files,
std::unique_ptr<base::Value> constants) { std::unique_ptr<base::Value> constants) {
return CreateInternal(log_path, SiblingInprogressDirectory(log_path), return CreateInternal(log_path, SiblingInprogressDirectory(log_path),
...@@ -433,7 +433,7 @@ std::unique_ptr<FileNetLogObserver> FileNetLogObserver::CreateInternal( ...@@ -433,7 +433,7 @@ std::unique_ptr<FileNetLogObserver> FileNetLogObserver::CreateInternal(
const base::FilePath& log_path, const base::FilePath& log_path,
const base::FilePath& inprogress_dir_path, const base::FilePath& inprogress_dir_path,
base::Optional<base::File> pre_existing_log_file, base::Optional<base::File> pre_existing_log_file,
size_t max_total_size, uint64_t max_total_size,
size_t total_num_event_files, size_t total_num_event_files,
std::unique_ptr<base::Value> constants) { std::unique_ptr<base::Value> constants) {
DCHECK_GT(total_num_event_files, 0u); DCHECK_GT(total_num_event_files, 0u);
...@@ -441,7 +441,7 @@ std::unique_ptr<FileNetLogObserver> FileNetLogObserver::CreateInternal( ...@@ -441,7 +441,7 @@ std::unique_ptr<FileNetLogObserver> FileNetLogObserver::CreateInternal(
scoped_refptr<base::SequencedTaskRunner> file_task_runner = scoped_refptr<base::SequencedTaskRunner> file_task_runner =
CreateFileTaskRunner(); CreateFileTaskRunner();
const size_t max_event_file_size = const uint64_t max_event_file_size =
max_total_size == kNoLimit ? kNoLimit max_total_size == kNoLimit ? kNoLimit
: max_total_size / total_num_event_files; : max_total_size / total_num_event_files;
...@@ -484,7 +484,7 @@ FileNetLogObserver::FileNetLogObserver( ...@@ -484,7 +484,7 @@ FileNetLogObserver::FileNetLogObserver(
base::Passed(&constants))); base::Passed(&constants)));
} }
FileNetLogObserver::WriteQueue::WriteQueue(size_t memory_max) FileNetLogObserver::WriteQueue::WriteQueue(uint64_t memory_max)
: memory_(0), memory_max_(memory_max) {} : memory_(0), memory_max_(memory_max) {}
size_t FileNetLogObserver::WriteQueue::AddEntryToQueue( size_t FileNetLogObserver::WriteQueue::AddEntryToQueue(
...@@ -517,7 +517,7 @@ FileNetLogObserver::FileWriter::FileWriter( ...@@ -517,7 +517,7 @@ FileNetLogObserver::FileWriter::FileWriter(
const base::FilePath& log_path, const base::FilePath& log_path,
const base::FilePath& inprogress_dir_path, const base::FilePath& inprogress_dir_path,
base::Optional<base::File> pre_existing_log_file, base::Optional<base::File> pre_existing_log_file,
size_t max_event_file_size, uint64_t max_event_file_size,
size_t total_num_event_files, size_t total_num_event_files,
scoped_refptr<base::SequencedTaskRunner> task_runner) scoped_refptr<base::SequencedTaskRunner> task_runner)
: final_log_path_(log_path), : final_log_path_(log_path),
......
...@@ -39,7 +39,7 @@ class NetLogCaptureMode; ...@@ -39,7 +39,7 @@ class NetLogCaptureMode;
class NET_EXPORT FileNetLogObserver : public NetLog::ThreadSafeObserver { class NET_EXPORT FileNetLogObserver : public NetLog::ThreadSafeObserver {
public: public:
// Special value meaning "can use an unlimited number of bytes". // Special value meaning "can use an unlimited number of bytes".
static constexpr size_t kNoLimit = std::numeric_limits<size_t>::max(); static constexpr uint64_t kNoLimit = std::numeric_limits<uint64_t>::max();
// Creates an instance of FileNetLogObserver that writes observed netlog // Creates an instance of FileNetLogObserver that writes observed netlog
// events to |log_path|. // events to |log_path|.
...@@ -58,7 +58,7 @@ class NET_EXPORT FileNetLogObserver : public NetLog::ThreadSafeObserver { ...@@ -58,7 +58,7 @@ class NET_EXPORT FileNetLogObserver : public NetLog::ThreadSafeObserver {
// If not present, the output of GetNetConstants() will be used. // If not present, the output of GetNetConstants() will be used.
static std::unique_ptr<FileNetLogObserver> CreateBounded( static std::unique_ptr<FileNetLogObserver> CreateBounded(
const base::FilePath& log_path, const base::FilePath& log_path,
size_t max_total_size, uint64_t max_total_size,
std::unique_ptr<base::Value> constants); std::unique_ptr<base::Value> constants);
// Shortcut for calling CreateBounded() with kNoLimit. // Shortcut for calling CreateBounded() with kNoLimit.
...@@ -73,7 +73,7 @@ class NET_EXPORT FileNetLogObserver : public NetLog::ThreadSafeObserver { ...@@ -73,7 +73,7 @@ class NET_EXPORT FileNetLogObserver : public NetLog::ThreadSafeObserver {
static std::unique_ptr<FileNetLogObserver> CreateBoundedPreExisting( static std::unique_ptr<FileNetLogObserver> CreateBoundedPreExisting(
const base::FilePath& inprogress_dir_path, const base::FilePath& inprogress_dir_path,
base::File output_file, base::File output_file,
size_t max_total_size, uint64_t max_total_size,
std::unique_ptr<base::Value> constants); std::unique_ptr<base::Value> constants);
// Creates an unbounded log that writes to a pre-existing file (truncating // Creates an unbounded log that writes to a pre-existing file (truncating
...@@ -111,7 +111,7 @@ class NET_EXPORT FileNetLogObserver : public NetLog::ThreadSafeObserver { ...@@ -111,7 +111,7 @@ class NET_EXPORT FileNetLogObserver : public NetLog::ThreadSafeObserver {
// |total_num_event_files|. // |total_num_event_files|.
static std::unique_ptr<FileNetLogObserver> CreateBoundedForTests( static std::unique_ptr<FileNetLogObserver> CreateBoundedForTests(
const base::FilePath& log_path, const base::FilePath& log_path,
size_t max_total_size, uint64_t max_total_size,
size_t total_num_event_files, size_t total_num_event_files,
std::unique_ptr<base::Value> constants); std::unique_ptr<base::Value> constants);
...@@ -123,7 +123,7 @@ class NET_EXPORT FileNetLogObserver : public NetLog::ThreadSafeObserver { ...@@ -123,7 +123,7 @@ class NET_EXPORT FileNetLogObserver : public NetLog::ThreadSafeObserver {
const base::FilePath& log_path, const base::FilePath& log_path,
const base::FilePath& inprogress_dir_path, const base::FilePath& inprogress_dir_path,
base::Optional<base::File> pre_existing_out_file, base::Optional<base::File> pre_existing_out_file,
size_t max_total_size, uint64_t max_total_size,
size_t total_num_event_files, size_t total_num_event_files,
std::unique_ptr<base::Value> constants); std::unique_ptr<base::Value> constants);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment