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

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

Issue 147593006: Refine error code returned by ServiceWorkerVersion::StartWorker (e.g. PROCESS_NOT_FOUND etc) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
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/bind.h" 5 #include "base/bind.h"
6 #include "base/callback.h" 6 #include "base/callback.h"
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "content/browser/service_worker/embedded_worker_instance.h" 10 #include "content/browser/service_worker/embedded_worker_instance.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); 124 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO));
125 worker_ = wrapper()->context()->embedded_worker_registry()->CreateWorker(); 125 worker_ = wrapper()->context()->embedded_worker_registry()->CreateWorker();
126 EXPECT_EQ(EmbeddedWorkerInstance::STOPPED, worker_->status()); 126 EXPECT_EQ(EmbeddedWorkerInstance::STOPPED, worker_->status());
127 worker_->AddObserver(this); 127 worker_->AddObserver(this);
128 128
129 AssociateProcessToWorker(worker_.get()); 129 AssociateProcessToWorker(worker_.get());
130 130
131 const int64 service_worker_version_id = 33L; 131 const int64 service_worker_version_id = 33L;
132 const GURL script_url = embedded_test_server()->GetURL( 132 const GURL script_url = embedded_test_server()->GetURL(
133 "/service_worker/worker.js"); 133 "/service_worker/worker.js");
134 const bool started = worker_->Start( 134 ServiceWorkerStatusCode status = worker_->Start(
135 service_worker_version_id, script_url); 135 service_worker_version_id, script_url);
136 136
137 last_worker_status_ = worker_->status(); 137 last_worker_status_ = worker_->status();
138 EXPECT_TRUE(started); 138 EXPECT_EQ(SERVICE_WORKER_OK, status);
139 EXPECT_EQ(EmbeddedWorkerInstance::STARTING, last_worker_status_); 139 EXPECT_EQ(EmbeddedWorkerInstance::STARTING, last_worker_status_);
140 140
141 if (!started && !done_closure_.is_null()) 141 if (status != SERVICE_WORKER_OK && !done_closure_.is_null())
142 done_closure_.Run(); 142 done_closure_.Run();
143 } 143 }
144 144
145 void StopOnIOThread() { 145 void StopOnIOThread() {
146 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); 146 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO));
147 EXPECT_EQ(EmbeddedWorkerInstance::RUNNING, worker_->status()); 147 EXPECT_EQ(EmbeddedWorkerInstance::RUNNING, worker_->status());
148 148
149 const bool stopped = worker_->Stop(); 149 ServiceWorkerStatusCode status = worker_->Stop();
150 150
151 last_worker_status_ = worker_->status(); 151 last_worker_status_ = worker_->status();
152 EXPECT_TRUE(stopped); 152 EXPECT_EQ(SERVICE_WORKER_OK, status);
153 EXPECT_EQ(EmbeddedWorkerInstance::STOPPING, last_worker_status_); 153 EXPECT_EQ(EmbeddedWorkerInstance::STOPPING, last_worker_status_);
154 154
155 if (!stopped && !done_closure_.is_null()) 155 if (status != SERVICE_WORKER_OK && !done_closure_.is_null())
156 done_closure_.Run(); 156 done_closure_.Run();
157 } 157 }
158 158
159 protected: 159 protected:
160 // EmbeddedWorkerInstance::Observer overrides: 160 // EmbeddedWorkerInstance::Observer overrides:
161 virtual void OnStarted() OVERRIDE { 161 virtual void OnStarted() OVERRIDE {
162 ASSERT_TRUE(worker_ != NULL); 162 ASSERT_TRUE(worker_ != NULL);
163 ASSERT_FALSE(done_closure_.is_null()); 163 ASSERT_FALSE(done_closure_.is_null());
164 last_worker_status_ = worker_->status(); 164 last_worker_status_ = worker_->status();
165 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, done_closure_); 165 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, done_closure_);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 base::RunLoop start_run_loop; 285 base::RunLoop start_run_loop;
286 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, 286 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
287 base::Bind(&self::StartOnIOThread, this, 287 base::Bind(&self::StartOnIOThread, this,
288 "/service_worker/nonexistent.js", 288 "/service_worker/nonexistent.js",
289 SERVICE_WORKER_ERROR_START_WORKER_FAILED, 289 SERVICE_WORKER_ERROR_START_WORKER_FAILED,
290 start_run_loop.QuitClosure())); 290 start_run_loop.QuitClosure()));
291 start_run_loop.Run(); 291 start_run_loop.Run();
292 } 292 }
293 293
294 } // namespace content 294 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698