Skip to content

Commit

Permalink
Revert 256579 "Allow the content browser client to specify a spe..."
Browse files Browse the repository at this point in the history
This broke the Android builders. The try-bots on the CL did point
out the compile errors, but it was committed manually anyway. Logs:

http://build.chromium.org/p/chromium.linux/builders/Android%20Clang%20Builder%20%28dbg%29/builds/30977/steps/compile/logs/stdio

> Allow the content browser client to specify a special cookie store to be
> used for a given render process id. This special cookie store will then
> be used for renderer messages pertaining to cookies, url fetches in net,
> and websockets. If the special cookie store is NULL, a default cookie store
> will be used.
> 
> R=erikwright@chromium.org, jam@chromium.org, lambroslambrou@chromium.org, mmenke@chromium.org, tyoshino@chromium.org
> 
> Review URL: https://codereview.chromium.org/188693003

TBR=tburkard@chromium.org

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@256583 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
peter@chromium.org committed Mar 12, 2014
1 parent 26ca33d commit a8030a2
Show file tree
Hide file tree
Showing 45 changed files with 204 additions and 336 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ scoped_ptr<net::URLRequest>
ChromeFraudulentCertificateReporter::CreateURLRequest(
net::URLRequestContext* context) {
scoped_ptr<net::URLRequest> request =
context->CreateRequest(upload_url_, net::DEFAULT_PRIORITY, this, NULL);
context->CreateRequest(upload_url_, net::DEFAULT_PRIORITY, this);
request->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES |
net::LOAD_DO_NOT_SAVE_COOKIES);
return request.Pass();
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/net/connection_tester.cc
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ void ConnectionTester::TestRunner::ProxyConfigServiceCreated(
}
// Fetch a request using the experimental context.
request_ = request_context_->CreateRequest(
experiment.url, net::DEFAULT_PRIORITY, this, NULL);
experiment.url, net::DEFAULT_PRIORITY, this);
request_->Start();
}

Expand Down
3 changes: 1 addition & 2 deletions chrome/browser/net/http_pipelining_compatibility_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ Request::Request(int request_id,
url_request_(url_request_context->CreateRequest(GURL(base_url +
info.filename),
net::DEFAULT_PRIORITY,
this,
NULL)),
this)),
info_(info),
response_code_(0) {
url_request_->SetLoadFlags(net::LOAD_BYPASS_CACHE |
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/plugins/plugin_installer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void BeginDownload(
ResourceDispatcherHost* rdh = ResourceDispatcherHost::Get();
scoped_ptr<net::URLRequest> request(
resource_context->GetRequestContext()->CreateRequest(
url, net::DEFAULT_PRIORITY, NULL, NULL));
url, net::DEFAULT_PRIORITY, NULL));
content::DownloadInterruptReason error = rdh->BeginDownload(
request.Pass(),
content::Referrer(),
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/ssl/ssl_client_certificate_selector_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,6 @@ SSLClientCertificateSelectorTestBase::MakeURLRequest(
net::URLRequestContextGetter* context_getter) {
scoped_ptr<net::URLRequest> request =
context_getter->GetURLRequestContext()->CreateRequest(
GURL("https://example"), net::DEFAULT_PRIORITY, NULL, NULL);
GURL("https://example"), net::DEFAULT_PRIORITY, NULL);
return request.Pass();
}
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class SSLClientCertificateSelectorTest : public InProcessBrowserTest {
scoped_ptr<net::URLRequest> MakeURLRequest(
net::URLRequestContextGetter* context_getter) {
return context_getter->GetURLRequestContext()->CreateRequest(
GURL("https://example"), net::DEFAULT_PRIORITY, NULL, NULL);
GURL("https://example"), net::DEFAULT_PRIORITY, NULL);
}

base::WaitableEvent io_loop_finished_event_;
Expand Down
2 changes: 1 addition & 1 deletion content/browser/download/download_manager_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void BeginDownload(scoped_ptr<DownloadUrlParameters> params,
// we must down cast. RDHI is the only subclass of RDH as of 2012 May 4.
scoped_ptr<net::URLRequest> request(
params->resource_context()->GetRequestContext()->CreateRequest(
params->url(), net::DEFAULT_PRIORITY, NULL, NULL));
params->url(), net::DEFAULT_PRIORITY, NULL));
request->SetLoadFlags(request->load_flags() | params->load_flags());
request->set_method(params->method());
if (!params->post_body().empty()) {
Expand Down
2 changes: 1 addition & 1 deletion content/browser/fileapi/blob_url_request_job_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ class BlobURLRequestJobTest : public testing::Test {
void TestRequest(const std::string& method,
const net::HttpRequestHeaders& extra_headers) {
request_ = url_request_context_.CreateRequest(
GURL("blob:blah"), net::DEFAULT_PRIORITY, &url_request_delegate_, NULL);
GURL("blob:blah"), net::DEFAULT_PRIORITY, &url_request_delegate_);
request_->set_method(method);
if (!extra_headers.IsEmpty())
request_->SetExtraRequestHeaders(extra_headers);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class FileSystemDirURLRequestJobTest : public testing::Test {
delegate_.reset(new net::TestDelegate());
delegate_->set_quit_on_redirect(true);
request_ = empty_context_.CreateRequest(
url, net::DEFAULT_PRIORITY, delegate_.get(), NULL);
url, net::DEFAULT_PRIORITY, delegate_.get());
job_ = new fileapi::FileSystemDirURLRequestJob(
request_.get(), NULL, file_system_context);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class FileSystemURLRequestJobTest : public testing::Test {
delegate_->set_quit_on_complete(true);
delegate_->set_quit_on_redirect(true);
request_ = empty_context_.CreateRequest(
url, net::DEFAULT_PRIORITY, delegate_.get(), NULL);
url, net::DEFAULT_PRIORITY, delegate_.get());
if (headers)
request_->SetExtraRequestHeaders(*headers);
ASSERT_TRUE(!job_);
Expand Down
4 changes: 2 additions & 2 deletions content/browser/fileapi/file_writer_delegate_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class FileWriterDelegateTest : public PlatformTest {
file_writer_delegate_.reset(
CreateWriterDelegate(test_file_path, offset, allowed_growth));
request_ = empty_context_.CreateRequest(
blob_url, net::DEFAULT_PRIORITY, file_writer_delegate_.get(), NULL);
blob_url, net::DEFAULT_PRIORITY, file_writer_delegate_.get());
}

static net::URLRequest::ProtocolFactory Factory;
Expand Down Expand Up @@ -334,7 +334,7 @@ TEST_F(FileWriterDelegateTest, WriteSuccessWithoutQuotaLimitConcurrent) {
// Credate another FileWriterDelegate for concurrent write.
file_writer_delegate2.reset(CreateWriterDelegate("test2", 0, kint64max));
request2 = empty_context_.CreateRequest(
kBlobURL2, net::DEFAULT_PRIORITY, file_writer_delegate2.get(), NULL);
kBlobURL2, net::DEFAULT_PRIORITY, file_writer_delegate2.get());

Result result, result2;
ASSERT_EQ(0, usage());
Expand Down
12 changes: 2 additions & 10 deletions content/browser/loader/resource_dispatcher_host_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1056,12 +1056,9 @@ void ResourceDispatcherHostImpl::BeginRequest(
}

// Construct the request.
net::CookieStore* cookie_store =
GetContentClient()->browser()->OverrideCookieStoreForRenderProcess(
child_id);
scoped_ptr<net::URLRequest> new_request;
new_request = request_context->CreateRequest(
request_data.url, request_data.priority, NULL, cookie_store);
request_data.url, request_data.priority, NULL);

new_request->set_method(request_data.method);
new_request->set_first_party_for_cookies(
Expand Down Expand Up @@ -1362,13 +1359,8 @@ void ResourceDispatcherHostImpl::BeginSaveFile(
return;
}

net::CookieStore* cookie_store =
GetContentClient()->browser()->OverrideCookieStoreForRenderProcess(
child_id);
scoped_ptr<net::URLRequest> request(
request_context->CreateRequest(url, net::DEFAULT_PRIORITY, NULL,
cookie_store));

request_context->CreateRequest(url, net::DEFAULT_PRIORITY, NULL));
request->set_method("GET");
SetReferrerForRequest(request.get(), referrer);

Expand Down
2 changes: 1 addition & 1 deletion content/browser/loader/resource_scheduler_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class ResourceSchedulerTest : public testing::Test {
net::RequestPriority priority,
int route_id) {
scoped_ptr<net::URLRequest> url_request(
context_.CreateRequest(GURL(url), priority, NULL, NULL));
context_.CreateRequest(GURL(url), priority, NULL));
ResourceRequestInfoImpl* info = new ResourceRequestInfoImpl(
PROCESS_TYPE_RENDERER, // process_type
kChildId, // child_id
Expand Down
53 changes: 17 additions & 36 deletions content/browser/renderer_host/render_message_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -583,9 +583,9 @@ void RenderMessageFilter::OnSetCookie(int render_frame_id,
if (GetContentClient()->browser()->AllowSetCookie(
url, first_party_for_cookies, cookie, resource_context_,
render_process_id_, render_frame_id, &options)) {
net::CookieStore* cookie_store = GetCookieStoreForURL(url);
net::URLRequestContext* context = GetRequestContextForURL(url);
// Pass a null callback since we don't care about when the 'set' completes.
cookie_store->SetCookieWithOptionsAsync(
context->cookie_store()->SetCookieWithOptionsAsync(
url, cookie, options, net::CookieMonster::SetCookiesCallback());
}
}
Expand All @@ -607,8 +607,9 @@ void RenderMessageFilter::OnGetCookies(int render_frame_id,
base::strlcpy(url_buf, url.spec().c_str(), arraysize(url_buf));
base::debug::Alias(url_buf);

net::CookieStore* cookie_store = GetCookieStoreForURL(url);
net::CookieMonster* cookie_monster = cookie_store->GetCookieMonster();
net::URLRequestContext* context = GetRequestContextForURL(url);
net::CookieMonster* cookie_monster =
context->cookie_store()->GetCookieMonster();
cookie_monster->GetAllCookiesForURLAsync(
url, base::Bind(&RenderMessageFilter::CheckPolicyForCookies, this,
render_frame_id, url, first_party_for_cookies,
Expand All @@ -634,8 +635,9 @@ void RenderMessageFilter::OnGetRawCookies(
// We check policy here to avoid sending back cookies that would not normally
// be applied to outbound requests for the given URL. Since this cookie info
// is visible in the developer tools, it is helpful to make it match reality.
net::CookieStore* cookie_store = GetCookieStoreForURL(url);
net::CookieMonster* cookie_monster = cookie_store->GetCookieMonster();
net::URLRequestContext* context = GetRequestContextForURL(url);
net::CookieMonster* cookie_monster =
context->cookie_store()->GetCookieMonster();
cookie_monster->GetAllCookiesForURLAsync(
url, base::Bind(&RenderMessageFilter::SendGetRawCookiesResponse,
this, reply_msg));
Expand All @@ -648,8 +650,8 @@ void RenderMessageFilter::OnDeleteCookie(const GURL& url,
if (!policy->CanAccessCookiesForOrigin(render_process_id_, url))
return;

net::CookieStore* cookie_store = GetCookieStoreForURL(url);
cookie_store->DeleteCookieAsync(url, cookie_name, base::Closure());
net::URLRequestContext* context = GetRequestContextForURL(url);
context->cookie_store()->DeleteCookieAsync(url, cookie_name, base::Closure());
}

void RenderMessageFilter::OnCookiesEnabled(
Expand Down Expand Up @@ -883,17 +885,9 @@ void RenderMessageFilter::OnDownloadUrl(const IPC::Message& message,
const base::string16& suggested_name) {
scoped_ptr<DownloadSaveInfo> save_info(new DownloadSaveInfo());
save_info->suggested_name = suggested_name;

// There may be a special cookie store that we could use for this download,
// rather than the default one. Since this feature is generally only used for
// proper render views, and not downloads, we do not need to retrieve the
// special cookie store here, but just initialize the request to use the
// default cookie store.
// TODO(tburkard): retrieve the appropriate special cookie store, if this
// is ever to be used for downloads as well.
scoped_ptr<net::URLRequest> request(
resource_context_->GetRequestContext()->CreateRequest(
url, net::DEFAULT_PRIORITY, NULL, NULL));
url, net::DEFAULT_PRIORITY, NULL));
RecordDownloadSource(INITIATED_BY_RENDERER);
resource_dispatcher_host_->BeginDownload(
request.Pass(),
Expand Down Expand Up @@ -926,30 +920,17 @@ void RenderMessageFilter::OnAllocateSharedMemory(
buffer_size, PeerHandle(), handle);
}

net::CookieStore* RenderMessageFilter::GetCookieStoreForURL(
net::URLRequestContext* RenderMessageFilter::GetRequestContextForURL(
const GURL& url) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));

net::URLRequestContext* context =
GetContentClient()->browser()->OverrideRequestContextForURL(
url, resource_context_);
if (!context)
context = request_context_->GetURLRequestContext();

// If we should use a special URLRequestContext rather than the default one,
// return the cookie store of that special URLRequestContext.
if (context)
return context->cookie_store();

// Otherwise, if there is a special cookie store to be used for this process,
// return that cookie store.
net::CookieStore* cookie_store =
GetContentClient()->browser()->OverrideCookieStoreForRenderProcess(
render_process_id_);
if (cookie_store)
return cookie_store;

// Otherwise, return the cookie store of the default request context used
// for this renderer.
return request_context_->GetURLRequestContext()->cookie_store();
return context;
}

#if defined(OS_POSIX) && !defined(TOOLKIT_GTK) && !defined(OS_ANDROID)
Expand Down Expand Up @@ -1072,14 +1053,14 @@ void RenderMessageFilter::CheckPolicyForCookies(
const GURL& first_party_for_cookies,
IPC::Message* reply_msg,
const net::CookieList& cookie_list) {
net::CookieStore* cookie_store = GetCookieStoreForURL(url);
net::URLRequestContext* context = GetRequestContextForURL(url);
// Check the policy for get cookies, and pass cookie_list to the
// TabSpecificContentSetting for logging purpose.
if (GetContentClient()->browser()->AllowGetCookie(
url, first_party_for_cookies, cookie_list, resource_context_,
render_process_id_, render_frame_id)) {
// Gets the cookies from cookie store if allowed.
cookie_store->GetCookiesWithOptionsAsync(
context->cookie_store()->GetCookiesWithOptionsAsync(
url, net::CookieOptions(),
base::Bind(&RenderMessageFilter::SendGetCookiesResponse,
this, reply_msg));
Expand Down
5 changes: 2 additions & 3 deletions content/browser/renderer_host/render_message_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ struct MediaLogEvent;
}

namespace net {
class CookieStore;
class KeygenHandler;
class URLRequestContext;
class URLRequestContextGetter;
Expand Down Expand Up @@ -109,10 +108,10 @@ class RenderMessageFilter : public BrowserMessageFilter {

int render_process_id() const { return render_process_id_; }

// Returns the correct net::CookieStore depending on what type of url is
// Returns the correct net::URLRequestContext depending on what type of url is
// given.
// Only call on the IO thread.
net::CookieStore* GetCookieStoreForURL(const GURL& url);
net::URLRequestContext* GetRequestContextForURL(const GURL& url);

private:
friend class BrowserThread;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,7 @@ void SocketStreamDispatcherHost::OnConnect(int render_frame_id,
// Note that the SocketStreamHost is responsible for checking that |url|
// is valid.
SocketStreamHost* socket_stream_host =
new SocketStreamHost(this, render_process_id_, render_frame_id,
socket_id);
new SocketStreamHost(this, render_frame_id, socket_id);
hosts_.AddWithID(socket_stream_host, socket_id);
socket_stream_host->Connect(url, GetURLRequestContext());
DVLOG(2) << "SocketStreamDispatcherHost::OnConnect -> " << socket_id;
Expand Down
11 changes: 3 additions & 8 deletions content/browser/renderer_host/socket_stream_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

#include "base/logging.h"
#include "content/common/socket_stream.h"
#include "content/public/browser/content_browser_client.h"
#include "net/socket_stream/socket_stream_job.h"
#include "net/url_request/url_request_context.h"

Expand All @@ -29,11 +28,9 @@ class SocketStreamId : public net::SocketStream::UserData {

SocketStreamHost::SocketStreamHost(
net::SocketStream::Delegate* delegate,
int child_id,
int render_frame_id,
int socket_id)
: delegate_(delegate),
child_id_(child_id),
render_frame_id_(render_frame_id),
socket_id_(socket_id) {
DCHECK_NE(socket_id_, kNoSocketId);
Expand All @@ -54,7 +51,7 @@ int SocketStreamHost::SocketIdFromSocketStream(

SocketStreamHost::~SocketStreamHost() {
VLOG(1) << "SocketStreamHost destructed socket_id=" << socket_id_;
job_->DetachContext();
job_->set_context(NULL);
job_->DetachDelegate();
}

Expand All @@ -63,10 +60,8 @@ void SocketStreamHost::Connect(const GURL& url,
VLOG(1) << "SocketStreamHost::Connect url=" << url;
job_ = net::SocketStreamJob::CreateSocketStreamJob(
url, delegate_, request_context->transport_security_state(),
request_context->ssl_config_service(),
request_context,
GetContentClient()->browser()->OverrideCookieStoreForRenderProcess(
child_id_));
request_context->ssl_config_service());
job_->set_context(request_context);
job_->SetUserData(kSocketIdKey, new SocketStreamId(socket_id_));
job_->Connect();
}
Expand Down
2 changes: 0 additions & 2 deletions content/browser/renderer_host/socket_stream_host.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ namespace content {
class SocketStreamHost {
public:
SocketStreamHost(net::SocketStream::Delegate* delegate,
int child_id,
int render_frame_id,
int socket_id);
~SocketStreamHost();
Expand Down Expand Up @@ -67,7 +66,6 @@ class SocketStreamHost {

private:
net::SocketStream::Delegate* delegate_;
int child_id_;
int render_frame_id_;
int socket_id_;

Expand Down
4 changes: 2 additions & 2 deletions content/browser/streams/stream_url_request_job_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class StreamURLRequestJobTest : public testing::Test {
const std::string& expected_response) {
net::TestDelegate delegate;
request_ = url_request_context_.CreateRequest(
url, net::DEFAULT_PRIORITY, &delegate, NULL);
url, net::DEFAULT_PRIORITY, &delegate);
request_->set_method(method);
if (!extra_headers.IsEmpty())
request_->SetExtraRequestHeaders(extra_headers);
Expand Down Expand Up @@ -134,7 +134,7 @@ TEST_F(StreamURLRequestJobTest, TestGetLargeStreamRequest) {
TEST_F(StreamURLRequestJobTest, TestGetNonExistentStreamRequest) {
net::TestDelegate delegate;
request_ = url_request_context_.CreateRequest(
kStreamURL, net::DEFAULT_PRIORITY, &delegate, NULL);
kStreamURL, net::DEFAULT_PRIORITY, &delegate);
request_->set_method("GET");
request_->Start();

Expand Down
5 changes: 0 additions & 5 deletions content/public/browser/content_browser_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,4 @@ bool ContentBrowserClient::IsPluginAllowedToUseDevChannelAPIs() {
return false;
}

net::CookieStore* ContentBrowserClient::OverrideCookieStoreForRenderProcess(
int render_process_id) {
return NULL;
}

} // namespace content
Loading

0 comments on commit a8030a2

Please sign in to comment.