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

Side by Side Diff: third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerContainer.cpp

Issue 2815313002: Reland of Move ScriptState::GetExecutionContext (Part 5) (Closed)
Patch Set: Created 3 years, 8 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 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 ScriptPromise promise = resolver->Promise(); 272 ScriptPromise promise = resolver->Promise();
273 273
274 if (!provider_) { 274 if (!provider_) {
275 resolver->Reject(DOMException::Create(kInvalidStateError, 275 resolver->Reject(DOMException::Create(kInvalidStateError,
276 "Failed to register a ServiceWorker: " 276 "Failed to register a ServiceWorker: "
277 "The document is in an invalid " 277 "The document is in an invalid "
278 "state.")); 278 "state."));
279 return promise; 279 return promise;
280 } 280 }
281 281
282 ExecutionContext* execution_context = script_state->GetExecutionContext(); 282 ExecutionContext* execution_context = ExecutionContext::From(script_state);
283 // FIXME: May be null due to worker termination: http://crbug.com/413518. 283 // FIXME: May be null due to worker termination: http://crbug.com/413518.
284 if (!execution_context) 284 if (!execution_context)
285 return ScriptPromise(); 285 return ScriptPromise();
286 286
287 KURL script_url = execution_context->CompleteURL(url); 287 KURL script_url = execution_context->CompleteURL(url);
288 script_url.RemoveFragmentIdentifier(); 288 script_url.RemoveFragmentIdentifier();
289 289
290 KURL pattern_url; 290 KURL pattern_url;
291 if (options.scope().IsNull()) 291 if (options.scope().IsNull())
292 pattern_url = KURL(script_url, "./"); 292 pattern_url = KURL(script_url, "./");
(...skipping 16 matching lines...) Expand all
309 ScriptPromise promise = resolver->Promise(); 309 ScriptPromise promise = resolver->Promise();
310 310
311 if (!provider_) { 311 if (!provider_) {
312 resolver->Reject(DOMException::Create(kInvalidStateError, 312 resolver->Reject(DOMException::Create(kInvalidStateError,
313 "Failed to get a " 313 "Failed to get a "
314 "ServiceWorkerRegistration: The " 314 "ServiceWorkerRegistration: The "
315 "document is in an invalid state.")); 315 "document is in an invalid state."));
316 return promise; 316 return promise;
317 } 317 }
318 318
319 ExecutionContext* execution_context = script_state->GetExecutionContext(); 319 ExecutionContext* execution_context = ExecutionContext::From(script_state);
320 // FIXME: May be null due to worker termination: http://crbug.com/413518. 320 // FIXME: May be null due to worker termination: http://crbug.com/413518.
321 if (!execution_context) 321 if (!execution_context)
322 return ScriptPromise(); 322 return ScriptPromise();
323 323
324 RefPtr<SecurityOrigin> document_origin = 324 RefPtr<SecurityOrigin> document_origin =
325 execution_context->GetSecurityOrigin(); 325 execution_context->GetSecurityOrigin();
326 String error_message; 326 String error_message;
327 if (!execution_context->IsSecureContext(error_message)) { 327 if (!execution_context->IsSecureContext(error_message)) {
328 resolver->Reject(DOMException::Create(kSecurityError, error_message)); 328 resolver->Reject(DOMException::Create(kSecurityError, error_message));
329 return promise; 329 return promise;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 ScriptPromise promise = resolver->Promise(); 366 ScriptPromise promise = resolver->Promise();
367 367
368 if (!provider_) { 368 if (!provider_) {
369 resolver->Reject( 369 resolver->Reject(
370 DOMException::Create(kInvalidStateError, 370 DOMException::Create(kInvalidStateError,
371 "Failed to get ServiceWorkerRegistration objects: " 371 "Failed to get ServiceWorkerRegistration objects: "
372 "The document is in an invalid state.")); 372 "The document is in an invalid state."));
373 return promise; 373 return promise;
374 } 374 }
375 375
376 ExecutionContext* execution_context = script_state->GetExecutionContext(); 376 ExecutionContext* execution_context = ExecutionContext::From(script_state);
377 RefPtr<SecurityOrigin> document_origin = 377 RefPtr<SecurityOrigin> document_origin =
378 execution_context->GetSecurityOrigin(); 378 execution_context->GetSecurityOrigin();
379 String error_message; 379 String error_message;
380 if (!execution_context->IsSecureContext(error_message)) { 380 if (!execution_context->IsSecureContext(error_message)) {
381 resolver->Reject(DOMException::Create(kSecurityError, error_message)); 381 resolver->Reject(DOMException::Create(kSecurityError, error_message));
382 return promise; 382 return promise;
383 } 383 }
384 384
385 KURL page_url = KURL(KURL(), document_origin->ToString()); 385 KURL page_url = KURL(KURL(), document_origin->ToString());
386 if (!SchemeRegistry::ShouldTreatURLSchemeAsAllowingServiceWorkers( 386 if (!SchemeRegistry::ShouldTreatURLSchemeAsAllowingServiceWorkers(
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 486
487 if (ServiceWorkerContainerClient* client = 487 if (ServiceWorkerContainerClient* client =
488 ServiceWorkerContainerClient::From(execution_context)) { 488 ServiceWorkerContainerClient::From(execution_context)) {
489 provider_ = client->Provider(); 489 provider_ = client->Provider();
490 if (provider_) 490 if (provider_)
491 provider_->SetClient(this); 491 provider_->SetClient(this);
492 } 492 }
493 } 493 }
494 494
495 } // namespace blink 495 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698