Commit 0a833f79 authored by olli.raula's avatar olli.raula Committed by Commit bot

Make ParametersToValue return scoped_ptr

Almost all consumers use already scoped_ptr
and one place is much simpler when changed to use scoped_ptr.

Review URL: https://codereview.chromium.org/1549483004

Cr-Commit-Position: refs/heads/master@{#367062}
parent 287a3f60
...@@ -162,10 +162,10 @@ base::Value* NetLog::Entry::ToValue() const { ...@@ -162,10 +162,10 @@ base::Value* NetLog::Entry::ToValue() const {
return entry_dict.release(); return entry_dict.release();
} }
base::Value* NetLog::Entry::ParametersToValue() const { scoped_ptr<base::Value> NetLog::Entry::ParametersToValue() const {
if (data_->parameters_callback) if (data_->parameters_callback)
return data_->parameters_callback->Run(capture_mode_).release(); return data_->parameters_callback->Run(capture_mode_);
return NULL; return nullptr;
} }
NetLog::EntryData::EntryData(EventType type, NetLog::EntryData::EntryData(EventType type,
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "base/callback_forward.h" #include "base/callback_forward.h"
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/observer_list.h" #include "base/observer_list.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "base/synchronization/lock.h" #include "base/synchronization/lock.h"
...@@ -138,7 +139,7 @@ class NET_EXPORT NetLog { ...@@ -138,7 +139,7 @@ class NET_EXPORT NetLog {
// Returns the parameters as a Value. Returns NULL if there are no // Returns the parameters as a Value. Returns NULL if there are no
// parameters. Caller takes ownership of returned Value. // parameters. Caller takes ownership of returned Value.
base::Value* ParametersToValue() const; scoped_ptr<base::Value> ParametersToValue() const;
private: private:
const EntryData* const data_; const EntryData* const data_;
......
...@@ -50,16 +50,14 @@ class TestNetLog::Observer : public NetLog::ThreadSafeObserver { ...@@ -50,16 +50,14 @@ class TestNetLog::Observer : public NetLog::ThreadSafeObserver {
void OnAddEntry(const NetLog::Entry& entry) override { void OnAddEntry(const NetLog::Entry& entry) override {
// Using Dictionaries instead of Values makes checking values a little // Using Dictionaries instead of Values makes checking values a little
// simpler. // simpler.
base::DictionaryValue* param_dict = nullptr; scoped_ptr<base::DictionaryValue> param_dict =
base::Value* param_value = entry.ParametersToValue(); base::DictionaryValue::From(entry.ParametersToValue());
if (param_value && !param_value->GetAsDictionary(&param_dict))
delete param_value;
// Only need to acquire the lock when accessing class variables. // Only need to acquire the lock when accessing class variables.
base::AutoLock lock(lock_); base::AutoLock lock(lock_);
entry_list_.push_back(TestNetLogEntry( entry_list_.push_back(TestNetLogEntry(entry.type(), base::TimeTicks::Now(),
entry.type(), base::TimeTicks::Now(), entry.source(), entry.phase(), entry.source(), entry.phase(),
scoped_ptr<base::DictionaryValue>(param_dict))); std::move(param_dict)));
} }
// Needs to be "mutable" to use it in GetEntries(). // Needs to be "mutable" to use it in GetEntries().
......
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