Commit baf35970 authored by dcheng's avatar dcheng Committed by Commit bot

Manual fixups in components/policy for scoped_refptr operator T* removal

BUG=110610

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

Cr-Commit-Position: refs/heads/master@{#292663}
parent d5dd8dd3
......@@ -9,6 +9,7 @@
#include "base/bind.h"
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "components/policy/core/common/cloud/mock_cloud_policy_client.h"
......@@ -204,8 +205,8 @@ class CloudPolicyClientTest : public testing::Test {
StrictMock<MockCloudPolicyClientObserver> observer_;
StrictMock<MockUploadCertificateObserver> upload_certificate_observer_;
scoped_ptr<CloudPolicyClient> client_;
// Cached weak pointer to the client's request context.
net::URLRequestContextGetter* request_context_;
// Pointer to the client's request context.
scoped_refptr<net::URLRequestContextGetter> request_context_;
};
TEST_F(CloudPolicyClientTest, Init) {
......
......@@ -15,6 +15,7 @@
#include "net/base/net_errors.h"
#include "net/http/http_response_headers.h"
#include "net/url_request/url_fetcher.h"
#include "net/url_request/url_request_context_getter.h"
#include "net/url_request/url_request_status.h"
#include "url/gurl.h"
......@@ -139,7 +140,7 @@ class DeviceManagementRequestJobImpl : public DeviceManagementRequestJob {
const std::string& agent_parameter,
const std::string& platform_parameter,
DeviceManagementService* service,
net::URLRequestContextGetter* request_context);
const scoped_refptr<net::URLRequestContextGetter>& request_context);
virtual ~DeviceManagementRequestJobImpl();
// Handles the URL request response.
......@@ -180,7 +181,7 @@ class DeviceManagementRequestJobImpl : public DeviceManagementRequestJob {
int retries_count_;
// The request context to use for this job.
net::URLRequestContextGetter* request_context_;
scoped_refptr<net::URLRequestContextGetter> request_context_;
DISALLOW_COPY_AND_ASSIGN(DeviceManagementRequestJobImpl);
};
......@@ -190,12 +191,13 @@ DeviceManagementRequestJobImpl::DeviceManagementRequestJobImpl(
const std::string& agent_parameter,
const std::string& platform_parameter,
DeviceManagementService* service,
net::URLRequestContextGetter* request_context)
const scoped_refptr<net::URLRequestContextGetter>& request_context)
: DeviceManagementRequestJob(type, agent_parameter, platform_parameter),
service_(service),
bypass_proxy_(false),
retries_count_(0),
request_context_(request_context) {}
request_context_(request_context) {
}
DeviceManagementRequestJobImpl::~DeviceManagementRequestJobImpl() {
service_->RemoveJob(this);
......@@ -298,7 +300,9 @@ GURL DeviceManagementRequestJobImpl::GetURL(
void DeviceManagementRequestJobImpl::ConfigureRequest(
net::URLFetcher* fetcher) {
fetcher->SetRequestContext(request_context_);
// TODO(dcheng): It might make sense to make this take a const
// scoped_refptr<T>& too eventually.
fetcher->SetRequestContext(request_context_.get());
fetcher->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES |
net::LOAD_DO_NOT_SAVE_COOKIES |
net::LOAD_DISABLE_CACHE |
......@@ -413,7 +417,7 @@ DeviceManagementService::~DeviceManagementService() {
DeviceManagementRequestJob* DeviceManagementService::CreateJob(
DeviceManagementRequestJob::JobType type,
net::URLRequestContextGetter* request_context) {
const scoped_refptr<net::URLRequestContextGetter>& request_context) {
return new DeviceManagementRequestJobImpl(
type,
configuration_->GetAgentParameter(),
......
......@@ -13,6 +13,7 @@
#include "base/basictypes.h"
#include "base/callback.h"
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "components/policy/core/common/cloud/cloud_policy_constants.h"
#include "components/policy/policy_export.h"
......@@ -132,7 +133,7 @@ class POLICY_EXPORT DeviceManagementService : public net::URLFetcherDelegate {
// the caller.
virtual DeviceManagementRequestJob* CreateJob(
DeviceManagementRequestJob::JobType type,
net::URLRequestContextGetter* request_context);
const scoped_refptr<net::URLRequestContextGetter>& request_context);
// Schedules a task to run |Initialize| after |delay_milliseconds| had passed.
void ScheduleInitialization(int64 delay_milliseconds);
......
......@@ -47,7 +47,8 @@ class MockDeviceManagementService : public DeviceManagementService {
virtual ~MockDeviceManagementService();
typedef DeviceManagementRequestJob* CreateJobFunction(
DeviceManagementRequestJob::JobType, net::URLRequestContextGetter*);
DeviceManagementRequestJob::JobType,
const scoped_refptr<net::URLRequestContextGetter>&);
MOCK_METHOD2(CreateJob, CreateJobFunction);
MOCK_METHOD7(
......
......@@ -223,11 +223,12 @@ void UserCloudPolicyStore::Load() {
// Start a new Load operation and have us get called back when it is
// complete.
base::PostTaskAndReplyWithResult(
background_task_runner(),
background_task_runner().get(),
FROM_HERE,
base::Bind(&LoadPolicyFromDisk, policy_path_, key_path_),
base::Bind(&UserCloudPolicyStore::PolicyLoaded,
weak_factory_.GetWeakPtr(), true));
weak_factory_.GetWeakPtr(),
true));
}
void UserCloudPolicyStore::PolicyLoaded(bool validate_in_background,
......
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