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

Side by Side Diff: Source/core/workers/SharedWorker.cpp

Issue 17885002: Use toDocument instead of static_cast<Document*>. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 5 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
« no previous file with comments | « Source/WebKit/chromium/src/WebWorkerClientImpl.cpp ('k') | Source/core/workers/Worker.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * Copyright (C) 2010 Apple Inc. All rights reserved. 3 * Copyright (C) 2010 Apple Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 inline SharedWorker::SharedWorker(ScriptExecutionContext* context) 48 inline SharedWorker::SharedWorker(ScriptExecutionContext* context)
49 : AbstractWorker(context) 49 : AbstractWorker(context)
50 { 50 {
51 ScriptWrappable::init(this); 51 ScriptWrappable::init(this);
52 } 52 }
53 53
54 PassRefPtr<SharedWorker> SharedWorker::create(ScriptExecutionContext* context, c onst String& url, const String& name, ExceptionCode& ec) 54 PassRefPtr<SharedWorker> SharedWorker::create(ScriptExecutionContext* context, c onst String& url, const String& name, ExceptionCode& ec)
55 { 55 {
56 ASSERT(isMainThread()); 56 ASSERT(isMainThread());
57 UseCounter::count(static_cast<Document*>(context)->domWindow(), UseCounter:: SharedWorkerStart); 57 UseCounter::count(toDocument(context)->domWindow(), UseCounter::SharedWorker Start);
58 58
59 RefPtr<SharedWorker> worker = adoptRef(new SharedWorker(context)); 59 RefPtr<SharedWorker> worker = adoptRef(new SharedWorker(context));
60 60
61 RefPtr<MessageChannel> channel = MessageChannel::create(context); 61 RefPtr<MessageChannel> channel = MessageChannel::create(context);
62 worker->m_port = channel->port1(); 62 worker->m_port = channel->port1();
63 OwnPtr<MessagePortChannel> remotePort = channel->port2()->disentangle(); 63 OwnPtr<MessagePortChannel> remotePort = channel->port2()->disentangle();
64 ASSERT(remotePort); 64 ASSERT(remotePort);
65 65
66 worker->suspendIfNeeded(); 66 worker->suspendIfNeeded();
67 67
68 KURL scriptURL = worker->resolveURL(url, ec); 68 KURL scriptURL = worker->resolveURL(url, ec);
69 if (scriptURL.isEmpty()) 69 if (scriptURL.isEmpty())
70 return 0; 70 return 0;
71 71
72 // We don't currently support nested workers, so workers can only be created from documents. 72 // We don't currently support nested workers, so workers can only be created from documents.
73 ASSERT_WITH_SECURITY_IMPLICATION(context->isDocument()); 73 ASSERT_WITH_SECURITY_IMPLICATION(context->isDocument());
74 Document* document = static_cast<Document*>(context); 74 Document* document = toDocument(context);
75 if (!document->securityOrigin()->canAccessSharedWorkers(document->topOrigin( ))) { 75 if (!document->securityOrigin()->canAccessSharedWorkers(document->topOrigin( ))) {
76 ec = SECURITY_ERR; 76 ec = SECURITY_ERR;
77 return 0; 77 return 0;
78 } 78 }
79 79
80 SharedWorkerRepository::connect(worker.get(), remotePort.release(), scriptUR L, name, ec); 80 SharedWorkerRepository::connect(worker.get(), remotePort.release(), scriptUR L, name, ec);
81 81
82 return worker.release(); 82 return worker.release();
83 } 83 }
84 84
85 SharedWorker::~SharedWorker() 85 SharedWorker::~SharedWorker()
86 { 86 {
87 } 87 }
88 88
89 const AtomicString& SharedWorker::interfaceName() const 89 const AtomicString& SharedWorker::interfaceName() const
90 { 90 {
91 return eventNames().interfaceForSharedWorker; 91 return eventNames().interfaceForSharedWorker;
92 } 92 }
93 93
94 } // namespace WebCore 94 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/WebKit/chromium/src/WebWorkerClientImpl.cpp ('k') | Source/core/workers/Worker.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698