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

Side by Side Diff: content/browser/service_worker/service_worker_controllee_request_handler_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/files/scoped_temp_dir.h" 5 #include "base/files/scoped_temp_dir.h"
6 #include "base/logging.h" 6 #include "base/logging.h"
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "content/browser/browser_thread_impl.h" 8 #include "content/browser/browser_thread_impl.h"
9 #include "content/browser/fileapi/mock_url_request_delegate.h" 9 #include "content/browser/fileapi/mock_url_request_delegate.h"
10 #include "content/browser/service_worker/embedded_worker_test_helper.h" 10 #include "content/browser/service_worker/embedded_worker_test_helper.h"
(...skipping 26 matching lines...) Expand all
37 37
38 virtual void SetUp() OVERRIDE { 38 virtual void SetUp() OVERRIDE {
39 helper_.reset(new EmbeddedWorkerTestHelper(kMockRenderProcessId)); 39 helper_.reset(new EmbeddedWorkerTestHelper(kMockRenderProcessId));
40 40
41 // A new unstored registration/version. 41 // A new unstored registration/version.
42 scope_ = GURL("http://host/scope/"); 42 scope_ = GURL("http://host/scope/");
43 script_url_ = GURL("http://host/script.js"); 43 script_url_ = GURL("http://host/script.js");
44 registration_ = new ServiceWorkerRegistration( 44 registration_ = new ServiceWorkerRegistration(
45 scope_, script_url_, 1L, context()->AsWeakPtr()); 45 scope_, script_url_, 1L, context()->AsWeakPtr());
46 version_ = new ServiceWorkerVersion( 46 version_ = new ServiceWorkerVersion(
47 registration_, 47 registration_.get(), 1L, context()->AsWeakPtr());
48 1L, context()->AsWeakPtr());
49 48
50 // An empty host. 49 // An empty host.
51 scoped_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost( 50 scoped_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost(
52 kMockRenderProcessId, 1 /* provider_id */, 51 kMockRenderProcessId, 1 /* provider_id */,
53 context()->AsWeakPtr(), NULL)); 52 context()->AsWeakPtr(), NULL));
54 provider_host_ = host->AsWeakPtr(); 53 provider_host_ = host->AsWeakPtr();
55 context()->AddProviderHost(host.Pass()); 54 context()->AddProviderHost(host.Pass());
56 55
57 context()->storage()->LazyInitialize(base::Bind(&EmptyCallback)); 56 context()->storage()->LazyInitialize(base::Bind(&EmptyCallback));
58 base::RunLoop().RunUntilIdle(); 57 base::RunLoop().RunUntilIdle();
(...skipping 15 matching lines...) Expand all
74 base::WeakPtr<ServiceWorkerProviderHost> provider_host_; 73 base::WeakPtr<ServiceWorkerProviderHost> provider_host_;
75 net::URLRequestContext url_request_context_; 74 net::URLRequestContext url_request_context_;
76 MockURLRequestDelegate url_request_delegate_; 75 MockURLRequestDelegate url_request_delegate_;
77 GURL scope_; 76 GURL scope_;
78 GURL script_url_; 77 GURL script_url_;
79 }; 78 };
80 79
81 TEST_F(ServiceWorkerControlleeRequestHandlerTest, ActivateWaitingVersion) { 80 TEST_F(ServiceWorkerControlleeRequestHandlerTest, ActivateWaitingVersion) {
82 // Store a registration that is installed but not activated yet. 81 // Store a registration that is installed but not activated yet.
83 version_->SetStatus(ServiceWorkerVersion::INSTALLED); 82 version_->SetStatus(ServiceWorkerVersion::INSTALLED);
84 registration_->SetWaitingVersion(version_); 83 registration_->SetWaitingVersion(version_.get());
85 context()->storage()->StoreRegistration( 84 context()->storage()->StoreRegistration(
86 registration_, version_, 85 registration_.get(),
86 version_.get(),
87 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); 87 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback));
88 base::RunLoop().RunUntilIdle(); 88 base::RunLoop().RunUntilIdle();
89 89
90 // Conduct a main resource load. 90 // Conduct a main resource load.
91 const GURL kDocUrl("http://host/scope/doc"); 91 const GURL kDocUrl("http://host/scope/doc");
92 scoped_ptr<net::URLRequest> request = url_request_context_.CreateRequest( 92 scoped_ptr<net::URLRequest> request = url_request_context_.CreateRequest(
93 kDocUrl, 93 kDocUrl,
94 net::DEFAULT_PRIORITY, 94 net::DEFAULT_PRIORITY,
95 &url_request_delegate_, 95 &url_request_delegate_,
96 NULL); 96 NULL);
(...skipping 20 matching lines...) Expand all
117 EXPECT_FALSE(sw_job->ShouldFallbackToNetwork()); 117 EXPECT_FALSE(sw_job->ShouldFallbackToNetwork());
118 EXPECT_TRUE(sw_job->ShouldForwardToServiceWorker()); 118 EXPECT_TRUE(sw_job->ShouldForwardToServiceWorker());
119 EXPECT_TRUE(version_->HasControllee()); 119 EXPECT_TRUE(version_->HasControllee());
120 120
121 // Navigations should trigger an update too. 121 // Navigations should trigger an update too.
122 handler.reset(NULL); 122 handler.reset(NULL);
123 EXPECT_TRUE(version_->update_timer_.IsRunning()); 123 EXPECT_TRUE(version_->update_timer_.IsRunning());
124 } 124 }
125 125
126 } // namespace content 126 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698