Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(813)

Unified Diff: net/log/net_log.cc

Issue 2315613002: Extracted NetLog class's inner enum types into their own enum classes and (Closed)
Patch Set: Ran "git cl format" on code. Much formatting ensued. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/log/net_log.h ('k') | net/log/net_log_event_type.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/log/net_log.cc
diff --git a/net/log/net_log.cc b/net/log/net_log.cc
index b038519651a229f369f5b64febb9430f1964bcda..8abaea44a4f363c6a8825f221ce410627a8a84af 100644
--- a/net/log/net_log.cc
+++ b/net/log/net_log.cc
@@ -110,10 +110,10 @@ std::unique_ptr<base::Value> NetLogString16Callback(
// LoadTimingInfo requires this be 0.
const uint32_t NetLog::Source::kInvalidId = 0;
-NetLog::Source::Source() : type(SOURCE_NONE), id(kInvalidId) {
-}
+NetLog::Source::Source() : type(NetLogSourceType::NONE), id(kInvalidId) {}
-NetLog::Source::Source(SourceType type, uint32_t id) : type(type), id(id) {}
+NetLog::Source::Source(NetLogSourceType type, uint32_t id)
+ : type(type), id(id) {}
bool NetLog::Source::IsValid() const {
return id != kInvalidId;
@@ -137,7 +137,7 @@ bool NetLog::Source::FromEventParameters(base::Value* event_params,
base::DictionaryValue* dict = NULL;
base::DictionaryValue* source_dict = NULL;
int source_id = -1;
- int source_type = NetLog::SOURCE_COUNT;
+ int source_type = static_cast<int>(NetLogSourceType::COUNT);
if (!event_params || !event_params->GetAsDictionary(&dict) ||
!dict->GetDictionary("source_dependency", &source_dict) ||
!source_dict->GetInteger("id", &source_id) ||
@@ -147,8 +147,8 @@ bool NetLog::Source::FromEventParameters(base::Value* event_params,
}
DCHECK_GE(source_id, 0);
- DCHECK_LT(source_type, NetLog::SOURCE_COUNT);
- *source = Source(static_cast<SourceType>(source_type), source_id);
+ DCHECK_LT(source_type, static_cast<int>(NetLogSourceType::COUNT));
+ *source = Source(static_cast<NetLogSourceType>(source_type), source_id);
return true;
}
@@ -186,17 +186,16 @@ std::unique_ptr<base::Value> NetLog::Entry::ParametersToValue() const {
return nullptr;
}
-NetLog::EntryData::EntryData(EventType type,
+NetLog::EntryData::EntryData(NetLogEventType type,
Source source,
- EventPhase phase,
+ NetLogEventPhase phase,
base::TimeTicks time,
const ParametersCallback* parameters_callback)
: type(type),
source(source),
phase(phase),
time(time),
- parameters_callback(parameters_callback) {
-}
+ parameters_callback(parameters_callback) {}
NetLog::EntryData::~EntryData() {
}
@@ -237,16 +236,16 @@ NetLog::NetLog() : last_id_(0), is_capturing_(0) {
NetLog::~NetLog() {
}
-void NetLog::AddGlobalEntry(EventType type) {
- AddEntry(type, Source(NetLog::SOURCE_NONE, NextID()), NetLog::PHASE_NONE,
- NULL);
+void NetLog::AddGlobalEntry(NetLogEventType type) {
+ AddEntry(type, Source(NetLogSourceType::NONE, NextID()),
+ NetLogEventPhase::NONE, NULL);
}
void NetLog::AddGlobalEntry(
- EventType type,
+ NetLogEventType type,
const NetLog::ParametersCallback& parameters_callback) {
- AddEntry(type, Source(NetLog::SOURCE_NONE, NextID()), NetLog::PHASE_NONE,
- &parameters_callback);
+ AddEntry(type, Source(NetLogSourceType::NONE, NextID()),
+ NetLogEventPhase::NONE, &parameters_callback);
}
uint32_t NetLog::NextID() {
@@ -301,10 +300,10 @@ std::string NetLog::TickCountToString(const base::TimeTicks& time) {
}
// static
-const char* NetLog::EventTypeToString(EventType event) {
+const char* NetLog::EventTypeToString(NetLogEventType event) {
switch (event) {
-#define EVENT_TYPE(label) \
- case TYPE_##label: \
+#define EVENT_TYPE(label) \
+ case NetLogEventType::label: \
return #label;
#include "net/log/net_log_event_type_list.h"
#undef EVENT_TYPE
@@ -317,17 +316,17 @@ const char* NetLog::EventTypeToString(EventType event) {
// static
base::Value* NetLog::GetEventTypesAsValue() {
std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
- for (int i = 0; i < EVENT_COUNT; ++i) {
- dict->SetInteger(EventTypeToString(static_cast<EventType>(i)), i);
+ for (int i = 0; i < static_cast<int>(NetLogEventType::COUNT); ++i) {
+ dict->SetInteger(EventTypeToString(static_cast<NetLogEventType>(i)), i);
}
return dict.release();
}
// static
-const char* NetLog::SourceTypeToString(SourceType source) {
+const char* NetLog::SourceTypeToString(NetLogSourceType source) {
switch (source) {
-#define SOURCE_TYPE(label) \
- case SOURCE_##label: \
+#define SOURCE_TYPE(label) \
+ case NetLogSourceType::label: \
return #label;
#include "net/log/net_log_source_type_list.h"
#undef SOURCE_TYPE
@@ -340,20 +339,20 @@ const char* NetLog::SourceTypeToString(SourceType source) {
// static
base::Value* NetLog::GetSourceTypesAsValue() {
std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
- for (int i = 0; i < SOURCE_COUNT; ++i) {
- dict->SetInteger(SourceTypeToString(static_cast<SourceType>(i)), i);
+ for (int i = 0; i < static_cast<int>(NetLogSourceType::COUNT); ++i) {
+ dict->SetInteger(SourceTypeToString(static_cast<NetLogSourceType>(i)), i);
}
return dict.release();
}
// static
-const char* NetLog::EventPhaseToString(EventPhase phase) {
+const char* NetLog::EventPhaseToString(NetLogEventPhase phase) {
switch (phase) {
- case PHASE_BEGIN:
+ case NetLogEventPhase::BEGIN:
return "PHASE_BEGIN";
- case PHASE_END:
+ case NetLogEventPhase::END:
return "PHASE_END";
- case PHASE_NONE:
+ case NetLogEventPhase::NONE:
return "PHASE_NONE";
}
NOTREACHED();
@@ -397,9 +396,9 @@ NetLog::ParametersCallback NetLog::StringCallback(const char* name,
return base::Bind(&NetLogString16Callback, name, value);
}
-void NetLog::AddEntry(EventType type,
+void NetLog::AddEntry(NetLogEventType type,
const Source& source,
- EventPhase phase,
+ NetLogEventPhase phase,
const NetLog::ParametersCallback* parameters_callback) {
if (!IsCapturing())
return;
@@ -415,8 +414,7 @@ BoundNetLog::~BoundNetLog() {
liveness_ = DEAD;
}
-void BoundNetLog::AddEntry(NetLog::EventType type,
- NetLog::EventPhase phase) const {
+void BoundNetLog::AddEntry(NetLogEventType type, NetLogEventPhase phase) const {
CrashIfInvalid();
if (!net_log_)
@@ -425,8 +423,8 @@ void BoundNetLog::AddEntry(NetLog::EventType type,
}
void BoundNetLog::AddEntry(
- NetLog::EventType type,
- NetLog::EventPhase phase,
+ NetLogEventType type,
+ NetLogEventPhase phase,
const NetLog::ParametersCallback& get_parameters) const {
CrashIfInvalid();
@@ -435,37 +433,37 @@ void BoundNetLog::AddEntry(
net_log_->AddEntry(type, source_, phase, &get_parameters);
}
-void BoundNetLog::AddEvent(NetLog::EventType type) const {
- AddEntry(type, NetLog::PHASE_NONE);
+void BoundNetLog::AddEvent(NetLogEventType type) const {
+ AddEntry(type, NetLogEventPhase::NONE);
}
void BoundNetLog::AddEvent(
- NetLog::EventType type,
+ NetLogEventType type,
const NetLog::ParametersCallback& get_parameters) const {
- AddEntry(type, NetLog::PHASE_NONE, get_parameters);
+ AddEntry(type, NetLogEventPhase::NONE, get_parameters);
}
-void BoundNetLog::BeginEvent(NetLog::EventType type) const {
- AddEntry(type, NetLog::PHASE_BEGIN);
+void BoundNetLog::BeginEvent(NetLogEventType type) const {
+ AddEntry(type, NetLogEventPhase::BEGIN);
}
void BoundNetLog::BeginEvent(
- NetLog::EventType type,
+ NetLogEventType type,
const NetLog::ParametersCallback& get_parameters) const {
- AddEntry(type, NetLog::PHASE_BEGIN, get_parameters);
+ AddEntry(type, NetLogEventPhase::BEGIN, get_parameters);
}
-void BoundNetLog::EndEvent(NetLog::EventType type) const {
- AddEntry(type, NetLog::PHASE_END);
+void BoundNetLog::EndEvent(NetLogEventType type) const {
+ AddEntry(type, NetLogEventPhase::END);
}
void BoundNetLog::EndEvent(
- NetLog::EventType type,
+ NetLogEventType type,
const NetLog::ParametersCallback& get_parameters) const {
- AddEntry(type, NetLog::PHASE_END, get_parameters);
+ AddEntry(type, NetLogEventPhase::END, get_parameters);
}
-void BoundNetLog::AddEventWithNetErrorCode(NetLog::EventType event_type,
+void BoundNetLog::AddEventWithNetErrorCode(NetLogEventType event_type,
int net_error) const {
DCHECK_NE(ERR_IO_PENDING, net_error);
if (net_error >= 0) {
@@ -475,7 +473,7 @@ void BoundNetLog::AddEventWithNetErrorCode(NetLog::EventType event_type,
}
}
-void BoundNetLog::EndEventWithNetErrorCode(NetLog::EventType event_type,
+void BoundNetLog::EndEventWithNetErrorCode(NetLogEventType event_type,
int net_error) const {
DCHECK_NE(ERR_IO_PENDING, net_error);
if (net_error >= 0) {
@@ -485,7 +483,7 @@ void BoundNetLog::EndEventWithNetErrorCode(NetLog::EventType event_type,
}
}
-void BoundNetLog::AddByteTransferEvent(NetLog::EventType event_type,
+void BoundNetLog::AddByteTransferEvent(NetLogEventType event_type,
int byte_count,
const char* bytes) const {
AddEvent(event_type, base::Bind(BytesTransferredCallback, byte_count, bytes));
@@ -497,7 +495,7 @@ bool BoundNetLog::IsCapturing() const {
}
// static
-BoundNetLog BoundNetLog::Make(NetLog* net_log, NetLog::SourceType source_type) {
+BoundNetLog BoundNetLog::Make(NetLog* net_log, NetLogSourceType source_type) {
if (!net_log)
return BoundNetLog();
« no previous file with comments | « net/log/net_log.h ('k') | net/log/net_log_event_type.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698