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