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

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

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

Powered by Google App Engine
This is Rietveld 408576698