Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: content/browser/service_worker/service_worker_url_request_job_unittest.cc

Issue 508433002: Remove implicit conversions from scoped_refptr to T* in content/browser/service_worker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/callback.h" 6 #include "base/callback.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "content/browser/fileapi/chrome_blob_storage_context.h" 10 #include "content/browser/fileapi/chrome_blob_storage_context.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 98
99 void SetUpWithHelper(EmbeddedWorkerTestHelper* helper) { 99 void SetUpWithHelper(EmbeddedWorkerTestHelper* helper) {
100 helper_.reset(helper); 100 helper_.reset(helper);
101 101
102 registration_ = new ServiceWorkerRegistration( 102 registration_ = new ServiceWorkerRegistration(
103 GURL("http://example.com/"), 103 GURL("http://example.com/"),
104 GURL("http://example.com/service_worker.js"), 104 GURL("http://example.com/service_worker.js"),
105 1L, 105 1L,
106 helper_->context()->AsWeakPtr()); 106 helper_->context()->AsWeakPtr());
107 version_ = new ServiceWorkerVersion( 107 version_ = new ServiceWorkerVersion(
108 registration_, 1L, helper_->context()->AsWeakPtr()); 108 registration_.get(), 1L, helper_->context()->AsWeakPtr());
109 109
110 scoped_ptr<ServiceWorkerProviderHost> provider_host( 110 scoped_ptr<ServiceWorkerProviderHost> provider_host(
111 new ServiceWorkerProviderHost( 111 new ServiceWorkerProviderHost(
112 kProcessID, kProviderID, helper_->context()->AsWeakPtr(), NULL)); 112 kProcessID, kProviderID, helper_->context()->AsWeakPtr(), NULL));
113 provider_host->AssociateRegistration(registration_); 113 provider_host->AssociateRegistration(registration_.get());
114 registration_->SetActiveVersion(version_.get()); 114 registration_->SetActiveVersion(version_.get());
115 115
116 ChromeBlobStorageContext* chrome_blob_storage_context = 116 ChromeBlobStorageContext* chrome_blob_storage_context =
117 ChromeBlobStorageContext::GetFor(browser_context_.get()); 117 ChromeBlobStorageContext::GetFor(browser_context_.get());
118 // Wait for chrome_blob_storage_context to finish initializing. 118 // Wait for chrome_blob_storage_context to finish initializing.
119 base::RunLoop().RunUntilIdle(); 119 base::RunLoop().RunUntilIdle();
120 storage::BlobStorageContext* blob_storage_context = 120 storage::BlobStorageContext* blob_storage_context =
121 chrome_blob_storage_context->context(); 121 chrome_blob_storage_context->context();
122 122
123 url_request_job_factory_.reset(new net::URLRequestJobFactoryImpl); 123 url_request_job_factory_.reset(new net::URLRequestJobFactoryImpl);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 212
213 TEST_F(ServiceWorkerURLRequestJobTest, BlobResponse) { 213 TEST_F(ServiceWorkerURLRequestJobTest, BlobResponse) {
214 ChromeBlobStorageContext* blob_storage_context = 214 ChromeBlobStorageContext* blob_storage_context =
215 ChromeBlobStorageContext::GetFor(browser_context_.get()); 215 ChromeBlobStorageContext::GetFor(browser_context_.get());
216 std::string expected_response; 216 std::string expected_response;
217 for (int i = 0; i < 1024; ++i) { 217 for (int i = 0; i < 1024; ++i) {
218 blob_data_->AppendData(kTestData); 218 blob_data_->AppendData(kTestData);
219 expected_response += kTestData; 219 expected_response += kTestData;
220 } 220 }
221 scoped_ptr<storage::BlobDataHandle> blob_handle = 221 scoped_ptr<storage::BlobDataHandle> blob_handle =
222 blob_storage_context->context()->AddFinishedBlob(blob_data_); 222 blob_storage_context->context()->AddFinishedBlob(blob_data_.get());
223 SetUpWithHelper(new BlobResponder(kProcessID, blob_handle->uuid())); 223 SetUpWithHelper(new BlobResponder(kProcessID, blob_handle->uuid()));
224 224
225 version_->SetStatus(ServiceWorkerVersion::ACTIVATED); 225 version_->SetStatus(ServiceWorkerVersion::ACTIVATED);
226 TestRequest(200, "OK", expected_response); 226 TestRequest(200, "OK", expected_response);
227 } 227 }
228 228
229 TEST_F(ServiceWorkerURLRequestJobTest, NonExistentBlobUUIDResponse) { 229 TEST_F(ServiceWorkerURLRequestJobTest, NonExistentBlobUUIDResponse) {
230 SetUpWithHelper(new BlobResponder(kProcessID, "blob-id:nothing-is-here")); 230 SetUpWithHelper(new BlobResponder(kProcessID, "blob-id:nothing-is-here"));
231 version_->SetStatus(ServiceWorkerVersion::ACTIVATED); 231 version_->SetStatus(ServiceWorkerVersion::ACTIVATED);
232 TestRequest(500, "Service Worker Response Error", std::string()); 232 TestRequest(500, "Service Worker Response Error", std::string());
233 } 233 }
234 234
235 // TODO(kinuko): Add more tests with different response data and also for 235 // TODO(kinuko): Add more tests with different response data and also for
236 // FallbackToNetwork case. 236 // FallbackToNetwork case.
237 237
238 } // namespace content 238 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698