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

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

Issue 1675613002: service worker: use 200 OK for update requests even in the no update case (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: asan and fix win compile? Created 4 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/browser/service_worker/embedded_worker_instance.h" 5 #include "content/browser/service_worker/embedded_worker_instance.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 EmbeddedWorkerInstance* instance_; 321 EmbeddedWorkerInstance* instance_;
322 322
323 StatusCallback start_callback_; 323 StatusCallback start_callback_;
324 ProcessAllocationState state_; 324 ProcessAllocationState state_;
325 325
326 base::WeakPtrFactory<StartTask> weak_factory_; 326 base::WeakPtrFactory<StartTask> weak_factory_;
327 327
328 DISALLOW_COPY_AND_ASSIGN(StartTask); 328 DISALLOW_COPY_AND_ASSIGN(StartTask);
329 }; 329 };
330 330
331 bool EmbeddedWorkerInstance::Listener::OnMessageReceived(
332 const IPC::Message& message) {
333 return false;
334 }
335
331 EmbeddedWorkerInstance::~EmbeddedWorkerInstance() { 336 EmbeddedWorkerInstance::~EmbeddedWorkerInstance() {
332 DCHECK(status_ == STOPPING || status_ == STOPPED) << status_; 337 DCHECK(status_ == STOPPING || status_ == STOPPED) << status_;
333 devtools_proxy_.reset(); 338 devtools_proxy_.reset();
334 if (registry_->GetWorker(embedded_worker_id_)) 339 if (registry_->GetWorker(embedded_worker_id_))
335 registry_->RemoveWorker(process_id(), embedded_worker_id_); 340 registry_->RemoveWorker(process_id(), embedded_worker_id_);
336 process_handle_.reset(); 341 process_handle_.reset();
337 } 342 }
338 343
339 void EmbeddedWorkerInstance::Start(int64_t service_worker_version_id, 344 void EmbeddedWorkerInstance::Start(int64_t service_worker_version_id,
340 const GURL& scope, 345 const GURL& scope,
341 const GURL& script_url, 346 const GURL& script_url,
342 const StatusCallback& callback) { 347 const StatusCallback& callback,
348 bool pause_after_download) {
343 if (!context_) { 349 if (!context_) {
344 callback.Run(SERVICE_WORKER_ERROR_ABORT); 350 callback.Run(SERVICE_WORKER_ERROR_ABORT);
345 // |this| may be destroyed by the callback. 351 // |this| may be destroyed by the callback.
346 return; 352 return;
347 } 353 }
348 DCHECK(status_ == STOPPED); 354 DCHECK(status_ == STOPPED);
349 355
350 // TODO(horo): If we will see crashes here, we have to find the root cause of 356 // TODO(horo): If we will see crashes here, we have to find the root cause of
351 // the invalid version ID. Otherwise change CHECK to DCHECK. 357 // the invalid version ID. Otherwise change CHECK to DCHECK.
352 CHECK_NE(service_worker_version_id, kInvalidServiceWorkerVersionId); 358 CHECK_NE(service_worker_version_id, kInvalidServiceWorkerVersionId);
353 start_timing_ = base::TimeTicks::Now(); 359 start_timing_ = base::TimeTicks::Now();
354 status_ = STARTING; 360 status_ = STARTING;
355 starting_phase_ = ALLOCATING_PROCESS; 361 starting_phase_ = ALLOCATING_PROCESS;
356 network_accessed_for_script_ = false; 362 network_accessed_for_script_ = false;
357 service_registry_.reset(new ServiceRegistryImpl()); 363 service_registry_.reset(new ServiceRegistryImpl());
358 FOR_EACH_OBSERVER(Listener, listener_list_, OnStarting()); 364 FOR_EACH_OBSERVER(Listener, listener_list_, OnStarting());
359 365
360 scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> params( 366 scoped_ptr<EmbeddedWorkerMsg_StartWorker_Params> params(
361 new EmbeddedWorkerMsg_StartWorker_Params()); 367 new EmbeddedWorkerMsg_StartWorker_Params());
362 params->embedded_worker_id = embedded_worker_id_; 368 params->embedded_worker_id = embedded_worker_id_;
363 params->service_worker_version_id = service_worker_version_id; 369 params->service_worker_version_id = service_worker_version_id;
364 params->scope = scope; 370 params->scope = scope;
365 params->script_url = script_url; 371 params->script_url = script_url;
366 params->worker_devtools_agent_route_id = MSG_ROUTING_NONE; 372 params->worker_devtools_agent_route_id = MSG_ROUTING_NONE;
367 params->wait_for_debugger = false; 373 params->wait_for_debugger = false;
374 params->pause_after_download = pause_after_download;
368 params->v8_cache_options = GetV8CacheOptions(); 375 params->v8_cache_options = GetV8CacheOptions();
369 376
370 inflight_start_task_.reset(new StartTask(this)); 377 inflight_start_task_.reset(new StartTask(this));
371 inflight_start_task_->Start(std::move(params), callback); 378 inflight_start_task_->Start(std::move(params), callback);
372 } 379 }
373 380
374 ServiceWorkerStatusCode EmbeddedWorkerInstance::Stop() { 381 ServiceWorkerStatusCode EmbeddedWorkerInstance::Stop() {
375 DCHECK(status_ == STARTING || status_ == RUNNING) << status_; 382 DCHECK(status_ == STARTING || status_ == RUNNING) << status_;
376 383
377 // Abort an inflight start task. 384 // Abort an inflight start task.
(...skipping 27 matching lines...) Expand all
405 ServiceWorkerStatusCode EmbeddedWorkerInstance::SendMessage( 412 ServiceWorkerStatusCode EmbeddedWorkerInstance::SendMessage(
406 const IPC::Message& message) { 413 const IPC::Message& message) {
407 DCHECK_NE(kInvalidEmbeddedWorkerThreadId, thread_id_); 414 DCHECK_NE(kInvalidEmbeddedWorkerThreadId, thread_id_);
408 if (status_ != RUNNING && status_ != STARTING) 415 if (status_ != RUNNING && status_ != STARTING)
409 return SERVICE_WORKER_ERROR_IPC_FAILED; 416 return SERVICE_WORKER_ERROR_IPC_FAILED;
410 return registry_->Send(process_id(), 417 return registry_->Send(process_id(),
411 new EmbeddedWorkerContextMsg_MessageToWorker( 418 new EmbeddedWorkerContextMsg_MessageToWorker(
412 thread_id_, embedded_worker_id_, message)); 419 thread_id_, embedded_worker_id_, message));
413 } 420 }
414 421
422 void EmbeddedWorkerInstance::ResumeAfterDownload() {
423 if (process_id() == ChildProcessHost::kInvalidUniqueID || status_ != STARTING)
424 return;
425 registry_->Send(process_id(), new EmbeddedWorkerMsg_ResumeAfterDownload(
426 embedded_worker_id_));
427 }
428
415 ServiceRegistry* EmbeddedWorkerInstance::GetServiceRegistry() { 429 ServiceRegistry* EmbeddedWorkerInstance::GetServiceRegistry() {
416 DCHECK(status_ == STARTING || status_ == RUNNING) << status_; 430 DCHECK(status_ == STARTING || status_ == RUNNING) << status_;
417 return service_registry_.get(); 431 return service_registry_.get();
418 } 432 }
419 433
420 EmbeddedWorkerInstance::EmbeddedWorkerInstance( 434 EmbeddedWorkerInstance::EmbeddedWorkerInstance(
421 base::WeakPtr<ServiceWorkerContextCore> context, 435 base::WeakPtr<ServiceWorkerContextCore> context,
422 int embedded_worker_id) 436 int embedded_worker_id)
423 : context_(context), 437 : context_(context),
424 registry_(context->embedded_worker_registry()), 438 registry_(context->embedded_worker_registry()),
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 case SCRIPT_READ_FINISHED: 717 case SCRIPT_READ_FINISHED:
704 return "Script read finished"; 718 return "Script read finished";
705 case STARTING_PHASE_MAX_VALUE: 719 case STARTING_PHASE_MAX_VALUE:
706 NOTREACHED(); 720 NOTREACHED();
707 } 721 }
708 NOTREACHED() << phase; 722 NOTREACHED() << phase;
709 return std::string(); 723 return std::string();
710 } 724 }
711 725
712 } // namespace content 726 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698