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

Side by Side Diff: third_party/WebKit/Source/web/SharedWorkerRepositoryClientImpl.cpp

Issue 2080623002: Revert "Remove OwnPtr from Blink." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #include "public/platform/WebMessagePortChannel.h" 43 #include "public/platform/WebMessagePortChannel.h"
44 #include "public/platform/WebString.h" 44 #include "public/platform/WebString.h"
45 #include "public/platform/WebURL.h" 45 #include "public/platform/WebURL.h"
46 #include "public/web/WebContentSecurityPolicy.h" 46 #include "public/web/WebContentSecurityPolicy.h"
47 #include "public/web/WebFrameClient.h" 47 #include "public/web/WebFrameClient.h"
48 #include "public/web/WebKit.h" 48 #include "public/web/WebKit.h"
49 #include "public/web/WebSharedWorker.h" 49 #include "public/web/WebSharedWorker.h"
50 #include "public/web/WebSharedWorkerCreationErrors.h" 50 #include "public/web/WebSharedWorkerCreationErrors.h"
51 #include "public/web/WebSharedWorkerRepositoryClient.h" 51 #include "public/web/WebSharedWorkerRepositoryClient.h"
52 #include "web/WebLocalFrameImpl.h" 52 #include "web/WebLocalFrameImpl.h"
53 #include "wtf/PtrUtil.h"
54 #include <memory>
55 53
56 namespace blink { 54 namespace blink {
57 55
58 // Callback class that keeps the SharedWorker and WebSharedWorker objects alive while connecting. 56 // Callback class that keeps the SharedWorker and WebSharedWorker objects alive while connecting.
59 class SharedWorkerConnector : private WebSharedWorkerConnector::ConnectListener { 57 class SharedWorkerConnector : private WebSharedWorkerConnector::ConnectListener {
60 public: 58 public:
61 SharedWorkerConnector(SharedWorker* worker, const KURL& url, const String& n ame, WebMessagePortChannelUniquePtr channel, std::unique_ptr<WebSharedWorkerConn ector> webWorkerConnector) 59 SharedWorkerConnector(SharedWorker* worker, const KURL& url, const String& n ame, WebMessagePortChannelUniquePtr channel, PassOwnPtr<WebSharedWorkerConnector > webWorkerConnector)
62 : m_worker(worker) 60 : m_worker(worker)
63 , m_url(url) 61 , m_url(url)
64 , m_name(name) 62 , m_name(name)
65 , m_webWorkerConnector(std::move(webWorkerConnector)) 63 , m_webWorkerConnector(std::move(webWorkerConnector))
66 , m_channel(std::move(channel)) { } 64 , m_channel(std::move(channel)) { }
67 65
68 virtual ~SharedWorkerConnector(); 66 virtual ~SharedWorkerConnector();
69 void connect(); 67 void connect();
70 68
71 private: 69 private:
72 // WebSharedWorkerConnector::ConnectListener overrides. 70 // WebSharedWorkerConnector::ConnectListener overrides.
73 void connected() override; 71 void connected() override;
74 void scriptLoadFailed() override; 72 void scriptLoadFailed() override;
75 73
76 Persistent<SharedWorker> m_worker; 74 Persistent<SharedWorker> m_worker;
77 KURL m_url; 75 KURL m_url;
78 String m_name; 76 String m_name;
79 std::unique_ptr<WebSharedWorkerConnector> m_webWorkerConnector; 77 OwnPtr<WebSharedWorkerConnector> m_webWorkerConnector;
80 WebMessagePortChannelUniquePtr m_channel; 78 WebMessagePortChannelUniquePtr m_channel;
81 }; 79 };
82 80
83 SharedWorkerConnector::~SharedWorkerConnector() 81 SharedWorkerConnector::~SharedWorkerConnector()
84 { 82 {
85 m_worker->setIsBeingConnected(false); 83 m_worker->setIsBeingConnected(false);
86 } 84 }
87 85
88 void SharedWorkerConnector::connect() 86 void SharedWorkerConnector::connect()
89 { 87 {
(...skipping 25 matching lines...) Expand all
115 DCHECK(m_client); 113 DCHECK(m_client);
116 114
117 // No nested workers (for now) - connect() should only be called from docume nt context. 115 // No nested workers (for now) - connect() should only be called from docume nt context.
118 DCHECK(worker->getExecutionContext()->isDocument()); 116 DCHECK(worker->getExecutionContext()->isDocument());
119 Document* document = toDocument(worker->getExecutionContext()); 117 Document* document = toDocument(worker->getExecutionContext());
120 118
121 // TODO(estark): this is broken, as it only uses the first header 119 // TODO(estark): this is broken, as it only uses the first header
122 // when multiple might have been sent. Fix by making the 120 // when multiple might have been sent. Fix by making the
123 // SharedWorkerConnector interface take a map that can contain 121 // SharedWorkerConnector interface take a map that can contain
124 // multiple headers. 122 // multiple headers.
125 std::unique_ptr<Vector<CSPHeaderAndType>> headers = worker->getExecutionCont ext()->contentSecurityPolicy()->headers(); 123 OwnPtr<Vector<CSPHeaderAndType>> headers = worker->getExecutionContext()->co ntentSecurityPolicy()->headers();
126 WebString header; 124 WebString header;
127 WebContentSecurityPolicyType headerType = WebContentSecurityPolicyTypeReport ; 125 WebContentSecurityPolicyType headerType = WebContentSecurityPolicyTypeReport ;
128 126
129 if (headers->size() > 0) { 127 if (headers->size() > 0) {
130 header = (*headers)[0].first; 128 header = (*headers)[0].first;
131 headerType = static_cast<WebContentSecurityPolicyType>((*headers)[0].sec ond); 129 headerType = static_cast<WebContentSecurityPolicyType>((*headers)[0].sec ond);
132 } 130 }
133 131
134 WebWorkerCreationError creationError; 132 WebWorkerCreationError creationError;
135 String unusedSecureContextError; 133 String unusedSecureContextError;
136 bool isSecureContext = worker->getExecutionContext()->isSecureContext(unused SecureContextError); 134 bool isSecureContext = worker->getExecutionContext()->isSecureContext(unused SecureContextError);
137 std::unique_ptr<WebSharedWorkerConnector> webWorkerConnector = wrapUnique(m_ client->createSharedWorkerConnector(url, name, getId(document), header, headerTy pe, worker->getExecutionContext()->securityContext().addressSpace(), isSecureCon text ? WebSharedWorkerCreationContextTypeSecure : WebSharedWorkerCreationContext TypeNonsecure, &creationError)); 135 OwnPtr<WebSharedWorkerConnector> webWorkerConnector = adoptPtr(m_client->cre ateSharedWorkerConnector(url, name, getId(document), header, headerType, worker- >getExecutionContext()->securityContext().addressSpace(), isSecureContext ? WebS haredWorkerCreationContextTypeSecure : WebSharedWorkerCreationContextTypeNonsecu re, &creationError));
138 if (creationError != WebWorkerCreationErrorNone) { 136 if (creationError != WebWorkerCreationErrorNone) {
139 if (creationError == WebWorkerCreationErrorURLMismatch) { 137 if (creationError == WebWorkerCreationErrorURLMismatch) {
140 // Existing worker does not match this url, so return an error back to the caller. 138 // Existing worker does not match this url, so return an error back to the caller.
141 exceptionState.throwDOMException(URLMismatchError, "The location of the SharedWorker named '" + name + "' does not exactly match the provided URL (' " + url.elidedString() + "')."); 139 exceptionState.throwDOMException(URLMismatchError, "The location of the SharedWorker named '" + name + "' does not exactly match the provided URL (' " + url.elidedString() + "').");
142 return; 140 return;
143 } else if (creationError == WebWorkerCreationErrorSecureContextMismatch) { 141 } else if (creationError == WebWorkerCreationErrorSecureContextMismatch) {
144 if (isSecureContext) { 142 if (isSecureContext) {
145 UseCounter::count(document, UseCounter::NonSecureSharedWorkerAcc essedFromSecureContext); 143 UseCounter::count(document, UseCounter::NonSecureSharedWorkerAcc essedFromSecureContext);
146 } else { 144 } else {
147 UseCounter::count(document, UseCounter::SecureSharedWorkerAccess edFromNonSecureContext); 145 UseCounter::count(document, UseCounter::SecureSharedWorkerAccess edFromNonSecureContext);
(...skipping 12 matching lines...) Expand all
160 DCHECK(m_client); 158 DCHECK(m_client);
161 m_client->documentDetached(getId(document)); 159 m_client->documentDetached(getId(document));
162 } 160 }
163 161
164 SharedWorkerRepositoryClientImpl::SharedWorkerRepositoryClientImpl(WebSharedWork erRepositoryClient* client) 162 SharedWorkerRepositoryClientImpl::SharedWorkerRepositoryClientImpl(WebSharedWork erRepositoryClient* client)
165 : m_client(client) 163 : m_client(client)
166 { 164 {
167 } 165 }
168 166
169 } // namespace blink 167 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698