Chromium Code Reviews| Index: content/browser/download/download_net_log_parameters.cc |
| diff --git a/content/browser/download/download_net_log_parameters.cc b/content/browser/download/download_net_log_parameters.cc |
| index 9bfd0de54b39d9204d98ea7e2f8fa43f09059beb..74af14fdbd89f976a35469fc2092e902b96470ae 100644 |
| --- a/content/browser/download/download_net_log_parameters.cc |
| +++ b/content/browser/download/download_net_log_parameters.cc |
| @@ -13,6 +13,195 @@ |
| namespace download_net_logs { |
| +namespace { |
| + |
| +static const char* download_type_names[] = { |
| + "NEW_DOWNLOAD", |
| + "HISTORY_IMPORT", |
| + "SAVE_PAGE_AS" |
| +}; |
| +static const char* download_safety_names[] = { |
| + "SAFE", |
| + "DANGEROUS", |
| + "DANGEROUS_BUT_VALIDATED" |
| +}; |
| + |
| +COMPILE_ASSERT(ARRAYSIZE_UNSAFE(download_type_names) == SRC_SAVE_PAGE_AS + 1, |
| + download_type_enum_has_changed); |
| +COMPILE_ASSERT(ARRAYSIZE_UNSAFE(download_safety_names) == |
| + content::DownloadItem::DANGEROUS_BUT_VALIDATED + 1, |
| + downloaditem_safety_state_enum_has_changed); |
| + |
| +} // namespace |
| + |
| +ItemActivatedParameters::ItemActivatedParameters( |
| + DownloadType download_type, |
| + int64 id, |
| + const std::string& original_url, |
| + const std::string& final_url, |
| + const std::string& intermediate_name, |
| + const std::string& suggested_name, |
| + content::DownloadItem::SafetyState safety_state, |
| + int64 start_offset) |
| + : type_(download_type), |
|
mmenke
2012/02/03 17:59:45
nit: Fix indent.
ahendrickson
2012/02/04 05:24:04
Done (made consistent in this file).
|
| + id_(id), |
| + original_url_(original_url), |
| + final_url_(final_url), |
| + intermediate_filename_(intermediate_name), |
| + suggested_final_filename_(suggested_name), |
| + safety_state_(safety_state), |
| + start_offset_(start_offset) { |
| +} |
| + |
| +ItemActivatedParameters::~ItemActivatedParameters() { |
| +} |
| + |
| +Value* ItemActivatedParameters::ToValue() const { |
| + DictionaryValue* dict = new DictionaryValue(); |
| + |
| + dict->SetString("type", download_type_names[type_]); |
| + dict->SetDouble("id", id_); |
|
mmenke
2012/02/03 17:59:45
Suggest you use a string instead of a double. Goe
ahendrickson
2012/02/04 05:24:04
Done.
|
| + dict->SetString("original_url", original_url_); |
| + dict->SetString("final_url", final_url_); |
| + dict->SetString("intermediate_name", intermediate_filename_); |
| + dict->SetString("suggested_name", suggested_final_filename_); |
| + dict->SetString("safety_state", download_safety_names[safety_state_]); |
| + dict->SetDouble("start_offset", start_offset_); |
| + |
| + return dict; |
| +} |
| + |
| +ItemCheckedParameters::ItemCheckedParameters( |
| + content::DownloadItem::SafetyState safety_state) |
| + : safety_state_(safety_state) { |
|
mmenke
2012/02/03 17:59:45
nit: Fix indent.
ahendrickson
2012/02/04 05:24:04
Done.
|
| +} |
| + |
| +Value* ItemCheckedParameters::ToValue() const { |
| + DictionaryValue* dict = new DictionaryValue(); |
| + |
| + dict->SetString("safety_state", download_safety_names[safety_state_]); |
| + |
| + return dict; |
| +} |
| + |
| +ItemInHistoryParameters::ItemInHistoryParameters(int64 handle) |
| + : db_handle_(handle) { |
| +} |
| + |
| +Value* ItemInHistoryParameters::ToValue() const { |
| + DictionaryValue* dict = new DictionaryValue(); |
| + |
| + dict->SetDouble("db_handle", db_handle_); |
| + |
| + return dict; |
| +} |
| + |
| +ItemUpdatedParameters::ItemUpdatedParameters( |
| + int64 bytes_so_far, const std::string& hash_state) |
| + : bytes_so_far_(bytes_so_far), hash_state_(hash_state) { |
| +} |
| + |
| +Value* ItemUpdatedParameters::ToValue() const { |
| + DictionaryValue* dict = new DictionaryValue(); |
| + |
| + dict->SetDouble("bytes_so_far", bytes_so_far_); |
| + dict->SetString("hash_state", |
| + base::HexEncode(hash_state_.data(), hash_state_.size())); |
| + |
| + return dict; |
| +} |
| + |
| +ItemRenamedParameters::ItemRenamedParameters( |
| + const std::string& old_filename, const std::string& new_filename) |
| + : old_filename_(old_filename), new_filename_(new_filename) { |
| +} |
| + |
| +Value* ItemRenamedParameters::ToValue() const { |
| + DictionaryValue* dict = new DictionaryValue(); |
| + |
| + dict->SetString("old_filename", old_filename_); |
| + dict->SetString("new_filename", new_filename_); |
| + |
| + return dict; |
| +} |
| + |
| +ItemInterruptedParameters::ItemInterruptedParameters( |
| + InterruptReason reason, |
| + int64 bytes_so_far, |
| + const std::string& hash_state) |
| + : reason_(reason), |
| + bytes_so_far_(bytes_so_far), |
| + hash_state_(hash_state) { |
| +} |
| + |
| +Value* ItemInterruptedParameters::ToValue() const { |
| + DictionaryValue* dict = new DictionaryValue(); |
| + |
| + dict->SetString("interrupt_reason", InterruptReasonDebugString(reason_)); |
| + dict->SetDouble("bytes_so_far", bytes_so_far_); |
| + dict->SetString("hash_state", |
| + base::HexEncode(hash_state_.data(), hash_state_.size())); |
| + |
| + return dict; |
| +} |
| + |
| +ItemResumedParameters::ItemResumedParameters( |
| + bool user_initiated, |
| + InterruptReason reason, |
| + int64 bytes_so_far, |
| + const std::string& hash_state) |
| + : user_initiated_(user_initiated), |
|
mmenke
2012/02/03 17:59:45
nit: Fix indent (And goes for the rest of this fi
ahendrickson
2012/02/04 05:24:04
Done.
|
| + reason_(reason), |
| + bytes_so_far_(bytes_so_far), |
| + hash_state_(hash_state) { |
| +} |
| + |
| +Value* ItemResumedParameters::ToValue() const { |
| + DictionaryValue* dict = new DictionaryValue(); |
| + |
| + dict->SetBoolean("user_initiated", user_initiated_); |
| + dict->SetString("interrupt_reason", InterruptReasonDebugString(reason_)); |
| + dict->SetDouble("bytes_so_far", bytes_so_far_); |
| + dict->SetString("hash_state", |
| + base::HexEncode(hash_state_.data(), hash_state_.size())); |
| + |
| + return dict; |
| +} |
| + |
| +ItemFinishedParameters::ItemFinishedParameters( |
| + int64 bytes_so_far, |
| + const std::string& final_hash) |
| + : bytes_so_far_(bytes_so_far), |
| + final_hash_(final_hash) { |
| +} |
| + |
| +Value* ItemFinishedParameters::ToValue() const { |
| + DictionaryValue* dict = new DictionaryValue(); |
| + |
| + dict->SetDouble("bytes_so_far", bytes_so_far_); |
| + dict->SetString("final_hash", |
| + base::HexEncode(final_hash_.data(), final_hash_.size())); |
| + |
| + return dict; |
| +} |
| + |
| +ItemCanceledParameters::ItemCanceledParameters( |
| + int64 bytes_so_far, |
| + const std::string& hash_state) |
| + : bytes_so_far_(bytes_so_far), |
| + hash_state_(hash_state) { |
| +} |
| + |
| +Value* ItemCanceledParameters::ToValue() const { |
| + DictionaryValue* dict = new DictionaryValue(); |
| + |
| + dict->SetDouble("bytes_so_far", bytes_so_far_); |
| + dict->SetString("hash_state", |
| + base::HexEncode(hash_state_.data(), hash_state_.size())); |
| + |
| + return dict; |
| +} |
| + |
| FileOpenedParameters::FileOpenedParameters( |
| const std::string& file_name, |
| int64 start_offset) |