/src/mozilla-central/dom/media/systemservices/MediaParent.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set sw=2 ts=8 et ft=cpp : */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
5 | | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #include "MediaParent.h" |
8 | | |
9 | | #include "mozilla/Base64.h" |
10 | | #include <mozilla/StaticMutex.h> |
11 | | |
12 | | #include "MediaUtils.h" |
13 | | #include "MediaEngine.h" |
14 | | #include "VideoUtils.h" |
15 | | #include "nsAutoPtr.h" |
16 | | #include "nsThreadUtils.h" |
17 | | #include "nsNetCID.h" |
18 | | #include "nsNetUtil.h" |
19 | | #include "nsIInputStream.h" |
20 | | #include "nsILineInputStream.h" |
21 | | #include "nsIOutputStream.h" |
22 | | #include "nsISafeOutputStream.h" |
23 | | #include "nsAppDirectoryServiceDefs.h" |
24 | | #include "nsISupportsImpl.h" |
25 | | #include "mozilla/Logging.h" |
26 | | |
27 | | #undef LOG |
28 | | mozilla::LazyLogModule gMediaParentLog("MediaParent"); |
29 | 0 | #define LOG(args) MOZ_LOG(gMediaParentLog, mozilla::LogLevel::Debug, args) |
30 | | |
31 | | // A file in the profile dir is used to persist mOriginKeys used to anonymize |
32 | | // deviceIds to be unique per origin, to avoid them being supercookies. |
33 | | |
34 | | #define ORIGINKEYS_FILE "enumerate_devices.txt" |
35 | 0 | #define ORIGINKEYS_VERSION "1" |
36 | | |
37 | | namespace mozilla { |
38 | | namespace media { |
39 | | |
40 | | StaticMutex sOriginKeyStoreMutex; |
41 | | static OriginKeyStore* sOriginKeyStore = nullptr; |
42 | | |
43 | | class OriginKeyStore : public nsISupports |
44 | | { |
45 | | NS_DECL_THREADSAFE_ISUPPORTS |
46 | | class OriginKey |
47 | | { |
48 | | public: |
49 | | static const size_t DecodedLength = 18; |
50 | | static const size_t EncodedLength = DecodedLength * 4 / 3; |
51 | | |
52 | | explicit OriginKey(const nsACString& aKey, int64_t aSecondsStamp = 0) // 0 = temporal |
53 | | : mKey(aKey) |
54 | 0 | , mSecondsStamp(aSecondsStamp) {} |
55 | | |
56 | | nsCString mKey; // Base64 encoded. |
57 | | int64_t mSecondsStamp; |
58 | | }; |
59 | | |
60 | | class OriginKeysTable |
61 | | { |
62 | | public: |
63 | 0 | OriginKeysTable() : mPersistCount(0) {} |
64 | | |
65 | | nsresult |
66 | | GetPrincipalKey(const ipc::PrincipalInfo& aPrincipalInfo, |
67 | | nsCString& aResult, bool aPersist = false) |
68 | 0 | { |
69 | 0 | nsAutoCString principalString; |
70 | 0 | PrincipalInfoToString(aPrincipalInfo, principalString); |
71 | 0 |
|
72 | 0 | OriginKey* key; |
73 | 0 | if (!mKeys.Get(principalString, &key)) { |
74 | 0 | nsCString salt; // Make a new one |
75 | 0 | nsresult rv = GenerateRandomName(salt, OriginKey::EncodedLength); |
76 | 0 | if (NS_WARN_IF(NS_FAILED(rv))) { |
77 | 0 | return rv; |
78 | 0 | } |
79 | 0 | key = new OriginKey(salt); |
80 | 0 | mKeys.Put(principalString, key); |
81 | 0 | } |
82 | 0 | if (aPersist && !key->mSecondsStamp) { |
83 | 0 | key->mSecondsStamp = PR_Now() / PR_USEC_PER_SEC; |
84 | 0 | mPersistCount++; |
85 | 0 | } |
86 | 0 | aResult = key->mKey; |
87 | 0 | return NS_OK; |
88 | 0 | } |
89 | | |
90 | | void Clear(int64_t aSinceWhen) |
91 | 0 | { |
92 | 0 | // Avoid int64_t* <-> void* casting offset |
93 | 0 | OriginKey since(nsCString(), aSinceWhen / PR_USEC_PER_SEC); |
94 | 0 | for (auto iter = mKeys.Iter(); !iter.Done(); iter.Next()) { |
95 | 0 | nsAutoPtr<OriginKey>& originKey = iter.Data(); |
96 | 0 | LOG((((originKey->mSecondsStamp >= since.mSecondsStamp)? |
97 | 0 | "%s: REMOVE %" PRId64 " >= %" PRId64 : |
98 | 0 | "%s: KEEP %" PRId64 " < %" PRId64), |
99 | 0 | __FUNCTION__, originKey->mSecondsStamp, since.mSecondsStamp)); |
100 | 0 |
|
101 | 0 | if (originKey->mSecondsStamp >= since.mSecondsStamp) { |
102 | 0 | iter.Remove(); |
103 | 0 | } |
104 | 0 | } |
105 | 0 | mPersistCount = 0; |
106 | 0 | } |
107 | | |
108 | | private: |
109 | | void |
110 | | PrincipalInfoToString(const ipc::PrincipalInfo& aPrincipalInfo, |
111 | | nsACString& aString) |
112 | 0 | { |
113 | 0 | switch (aPrincipalInfo.type()) { |
114 | 0 | case ipc::PrincipalInfo::TSystemPrincipalInfo: |
115 | 0 | aString.AssignLiteral("[System Principal]"); |
116 | 0 | return; |
117 | 0 |
|
118 | 0 | case ipc::PrincipalInfo::TNullPrincipalInfo: { |
119 | 0 | const ipc::NullPrincipalInfo& info = |
120 | 0 | aPrincipalInfo.get_NullPrincipalInfo(); |
121 | 0 | aString.Assign(info.spec()); |
122 | 0 | return; |
123 | 0 | } |
124 | 0 |
|
125 | 0 | case ipc::PrincipalInfo::TContentPrincipalInfo: { |
126 | 0 | const ipc::ContentPrincipalInfo& info = |
127 | 0 | aPrincipalInfo.get_ContentPrincipalInfo(); |
128 | 0 | aString.Assign(info.originNoSuffix()); |
129 | 0 |
|
130 | 0 | nsAutoCString suffix; |
131 | 0 | info.attrs().CreateSuffix(suffix); |
132 | 0 | aString.Append(suffix); |
133 | 0 | return; |
134 | 0 | } |
135 | 0 |
|
136 | 0 | case ipc::PrincipalInfo::TExpandedPrincipalInfo: { |
137 | 0 | const ipc::ExpandedPrincipalInfo& info = |
138 | 0 | aPrincipalInfo.get_ExpandedPrincipalInfo(); |
139 | 0 |
|
140 | 0 | aString.AssignLiteral("[Expanded Principal ["); |
141 | 0 |
|
142 | 0 | for (uint32_t i = 0; i < info.whitelist().Length(); i++) { |
143 | 0 | nsAutoCString str; |
144 | 0 | PrincipalInfoToString(info.whitelist()[i], str); |
145 | 0 |
|
146 | 0 | if (i != 0) { |
147 | 0 | aString.AppendLiteral(", "); |
148 | 0 | } |
149 | 0 |
|
150 | 0 | aString.Append(str); |
151 | 0 | } |
152 | 0 |
|
153 | 0 | aString.AppendLiteral("]]"); |
154 | 0 | return; |
155 | 0 | } |
156 | 0 |
|
157 | 0 | default: |
158 | 0 | MOZ_CRASH("Unknown PrincipalInfo type!"); |
159 | 0 | } |
160 | 0 | } |
161 | | |
162 | | protected: |
163 | | nsClassHashtable<nsCStringHashKey, OriginKey> mKeys; |
164 | | size_t mPersistCount; |
165 | | }; |
166 | | |
167 | | class OriginKeysLoader : public OriginKeysTable |
168 | | { |
169 | | public: |
170 | 0 | OriginKeysLoader() {} |
171 | | |
172 | | nsresult |
173 | | GetPrincipalKey(const ipc::PrincipalInfo& aPrincipalInfo, |
174 | | nsCString& aResult, bool aPersist = false) |
175 | 0 | { |
176 | 0 | auto before = mPersistCount; |
177 | 0 | nsresult rv = OriginKeysTable::GetPrincipalKey(aPrincipalInfo, aResult, |
178 | 0 | aPersist); |
179 | 0 | if (NS_WARN_IF(NS_FAILED(rv))) { |
180 | 0 | return rv; |
181 | 0 | } |
182 | 0 | |
183 | 0 | if (mPersistCount != before) { |
184 | 0 | Save(); |
185 | 0 | } |
186 | 0 | return NS_OK; |
187 | 0 | } |
188 | | |
189 | | already_AddRefed<nsIFile> |
190 | | GetFile() |
191 | 0 | { |
192 | 0 | MOZ_ASSERT(mProfileDir); |
193 | 0 | nsCOMPtr<nsIFile> file; |
194 | 0 | nsresult rv = mProfileDir->Clone(getter_AddRefs(file)); |
195 | 0 | if (NS_WARN_IF(NS_FAILED(rv))) { |
196 | 0 | return nullptr; |
197 | 0 | } |
198 | 0 | file->Append(NS_LITERAL_STRING(ORIGINKEYS_FILE)); |
199 | 0 | return file.forget(); |
200 | 0 | } |
201 | | |
202 | | // Format of file is key secondsstamp origin (first line is version #): |
203 | | // |
204 | | // 1 |
205 | | // rOMAAbFujNwKyIpj4RJ3Wt5Q 1424733961 http://fiddle.jshell.net |
206 | | // rOMAAbFujNwKyIpj4RJ3Wt5Q 1424734841 http://mozilla.github.io |
207 | | // etc. |
208 | | |
209 | | nsresult Read() |
210 | 0 | { |
211 | 0 | nsCOMPtr<nsIFile> file = GetFile(); |
212 | 0 | if (NS_WARN_IF(!file)) { |
213 | 0 | return NS_ERROR_UNEXPECTED; |
214 | 0 | } |
215 | 0 | bool exists; |
216 | 0 | nsresult rv = file->Exists(&exists); |
217 | 0 | if (NS_WARN_IF(NS_FAILED(rv))) { |
218 | 0 | return rv; |
219 | 0 | } |
220 | 0 | if (!exists) { |
221 | 0 | return NS_OK; |
222 | 0 | } |
223 | 0 | |
224 | 0 | nsCOMPtr<nsIInputStream> stream; |
225 | 0 | rv = NS_NewLocalFileInputStream(getter_AddRefs(stream), file); |
226 | 0 | if (NS_WARN_IF(NS_FAILED(rv))) { |
227 | 0 | return rv; |
228 | 0 | } |
229 | 0 | nsCOMPtr<nsILineInputStream> i = do_QueryInterface(stream); |
230 | 0 | MOZ_ASSERT(i); |
231 | 0 | MOZ_ASSERT(!mPersistCount); |
232 | 0 |
|
233 | 0 | nsCString line; |
234 | 0 | bool hasMoreLines; |
235 | 0 | rv = i->ReadLine(line, &hasMoreLines); |
236 | 0 | if (NS_WARN_IF(NS_FAILED(rv))) { |
237 | 0 | return rv; |
238 | 0 | } |
239 | 0 | if (!line.EqualsLiteral(ORIGINKEYS_VERSION)) { |
240 | 0 | // If version on disk is newer than we can understand then ignore it. |
241 | 0 | return NS_OK; |
242 | 0 | } |
243 | 0 | |
244 | 0 | while (hasMoreLines) { |
245 | 0 | rv = i->ReadLine(line, &hasMoreLines); |
246 | 0 | if (NS_WARN_IF(NS_FAILED(rv))) { |
247 | 0 | return rv; |
248 | 0 | } |
249 | 0 | // Read key secondsstamp origin. |
250 | 0 | // Ignore any lines that don't fit format in the comment above exactly. |
251 | 0 | int32_t f = line.FindChar(' '); |
252 | 0 | if (f < 0) { |
253 | 0 | continue; |
254 | 0 | } |
255 | 0 | const nsACString& key = Substring(line, 0, f); |
256 | 0 | const nsACString& s = Substring(line, f+1); |
257 | 0 | f = s.FindChar(' '); |
258 | 0 | if (f < 0) { |
259 | 0 | continue; |
260 | 0 | } |
261 | 0 | int64_t secondsstamp = nsCString(Substring(s, 0, f)).ToInteger64(&rv); |
262 | 0 | if (NS_FAILED(rv)) { |
263 | 0 | continue; |
264 | 0 | } |
265 | 0 | const nsACString& origin = Substring(s, f+1); |
266 | 0 |
|
267 | 0 | // Validate key |
268 | 0 | if (key.Length() != OriginKey::EncodedLength) { |
269 | 0 | continue; |
270 | 0 | } |
271 | 0 | nsCString dummy; |
272 | 0 | rv = Base64Decode(key, dummy); |
273 | 0 | if (NS_FAILED(rv)) { |
274 | 0 | continue; |
275 | 0 | } |
276 | 0 | mKeys.Put(origin, new OriginKey(key, secondsstamp)); |
277 | 0 | } |
278 | 0 | mPersistCount = mKeys.Count(); |
279 | 0 | return NS_OK; |
280 | 0 | } |
281 | | |
282 | | nsresult |
283 | | Write() |
284 | 0 | { |
285 | 0 | nsCOMPtr<nsIFile> file = GetFile(); |
286 | 0 | if (NS_WARN_IF(!file)) { |
287 | 0 | return NS_ERROR_UNEXPECTED; |
288 | 0 | } |
289 | 0 | |
290 | 0 | nsCOMPtr<nsIOutputStream> stream; |
291 | 0 | nsresult rv = NS_NewSafeLocalFileOutputStream(getter_AddRefs(stream), file); |
292 | 0 | if (NS_WARN_IF(NS_FAILED(rv))) { |
293 | 0 | return rv; |
294 | 0 | } |
295 | 0 | |
296 | 0 | nsAutoCString versionBuffer; |
297 | 0 | versionBuffer.AppendLiteral(ORIGINKEYS_VERSION); |
298 | 0 | versionBuffer.Append('\n'); |
299 | 0 |
|
300 | 0 | uint32_t count; |
301 | 0 | rv = stream->Write(versionBuffer.Data(), versionBuffer.Length(), &count); |
302 | 0 | if (NS_WARN_IF(NS_FAILED(rv))) { |
303 | 0 | return rv; |
304 | 0 | } |
305 | 0 | if (count != versionBuffer.Length()) { |
306 | 0 | return NS_ERROR_UNEXPECTED; |
307 | 0 | } |
308 | 0 | for (auto iter = mKeys.Iter(); !iter.Done(); iter.Next()) { |
309 | 0 | const nsACString& origin = iter.Key(); |
310 | 0 | OriginKey* originKey = iter.UserData(); |
311 | 0 |
|
312 | 0 | if (!originKey->mSecondsStamp) { |
313 | 0 | continue; // don't write temporal ones |
314 | 0 | } |
315 | 0 | |
316 | 0 | nsCString originBuffer; |
317 | 0 | originBuffer.Append(originKey->mKey); |
318 | 0 | originBuffer.Append(' '); |
319 | 0 | originBuffer.AppendInt(originKey->mSecondsStamp); |
320 | 0 | originBuffer.Append(' '); |
321 | 0 | originBuffer.Append(origin); |
322 | 0 | originBuffer.Append('\n'); |
323 | 0 |
|
324 | 0 | rv = stream->Write(originBuffer.Data(), originBuffer.Length(), &count); |
325 | 0 | if (NS_WARN_IF(NS_FAILED(rv)) || count != originBuffer.Length()) { |
326 | 0 | break; |
327 | 0 | } |
328 | 0 | } |
329 | 0 |
|
330 | 0 | nsCOMPtr<nsISafeOutputStream> safeStream = do_QueryInterface(stream); |
331 | 0 | MOZ_ASSERT(safeStream); |
332 | 0 |
|
333 | 0 | rv = safeStream->Finish(); |
334 | 0 | if (NS_WARN_IF(NS_FAILED(rv))) { |
335 | 0 | return rv; |
336 | 0 | } |
337 | 0 | return NS_OK; |
338 | 0 | } |
339 | | |
340 | | nsresult Load() |
341 | 0 | { |
342 | 0 | nsresult rv = Read(); |
343 | 0 | if (NS_WARN_IF(NS_FAILED(rv))) { |
344 | 0 | Delete(); |
345 | 0 | } |
346 | 0 | return rv; |
347 | 0 | } |
348 | | |
349 | | nsresult Save() |
350 | 0 | { |
351 | 0 | nsresult rv = Write(); |
352 | 0 | if (NS_WARN_IF(NS_FAILED(rv))) { |
353 | 0 | NS_WARNING("Failed to write data for EnumerateDevices id-persistence."); |
354 | 0 | Delete(); |
355 | 0 | } |
356 | 0 | return rv; |
357 | 0 | } |
358 | | |
359 | | void Clear(int64_t aSinceWhen) |
360 | 0 | { |
361 | 0 | OriginKeysTable::Clear(aSinceWhen); |
362 | 0 | Delete(); |
363 | 0 | Save(); |
364 | 0 | } |
365 | | |
366 | | nsresult Delete() |
367 | 0 | { |
368 | 0 | nsCOMPtr<nsIFile> file = GetFile(); |
369 | 0 | if (NS_WARN_IF(!file)) { |
370 | 0 | return NS_ERROR_UNEXPECTED; |
371 | 0 | } |
372 | 0 | nsresult rv = file->Remove(false); |
373 | 0 | if (rv == NS_ERROR_FILE_NOT_FOUND) { |
374 | 0 | return NS_OK; |
375 | 0 | } |
376 | 0 | if (NS_WARN_IF(NS_FAILED(rv))) { |
377 | 0 | return rv; |
378 | 0 | } |
379 | 0 | return NS_OK; |
380 | 0 | } |
381 | | |
382 | | void |
383 | | SetProfileDir(nsIFile* aProfileDir) |
384 | 0 | { |
385 | 0 | MOZ_ASSERT(!NS_IsMainThread()); |
386 | 0 | bool first = !mProfileDir; |
387 | 0 | mProfileDir = aProfileDir; |
388 | 0 | // Load from disk when we first get a profileDir, but not subsequently. |
389 | 0 | if (first) { |
390 | 0 | Load(); |
391 | 0 | } |
392 | 0 | } |
393 | | private: |
394 | | nsCOMPtr<nsIFile> mProfileDir; |
395 | | }; |
396 | | |
397 | | private: |
398 | | virtual ~OriginKeyStore() |
399 | 0 | { |
400 | 0 | StaticMutexAutoLock lock(sOriginKeyStoreMutex); |
401 | 0 | sOriginKeyStore = nullptr; |
402 | 0 | LOG((__FUNCTION__)); |
403 | 0 | } |
404 | | |
405 | | public: |
406 | | static OriginKeyStore* Get() |
407 | 0 | { |
408 | 0 | MOZ_ASSERT(NS_IsMainThread()); |
409 | 0 | StaticMutexAutoLock lock(sOriginKeyStoreMutex); |
410 | 0 | if (!sOriginKeyStore) { |
411 | 0 | sOriginKeyStore = new OriginKeyStore(); |
412 | 0 | } |
413 | 0 | return sOriginKeyStore; |
414 | 0 | } |
415 | | |
416 | | // Only accessed on StreamTS thread |
417 | | OriginKeysLoader mOriginKeys; |
418 | | OriginKeysTable mPrivateBrowsingOriginKeys; |
419 | | }; |
420 | | |
421 | | NS_IMPL_ISUPPORTS0(OriginKeyStore) |
422 | | |
423 | | bool NonE10s::SendGetPrincipalKeyResponse(const uint32_t& aRequestId, |
424 | 0 | nsCString aKey) { |
425 | 0 | MediaManager* mgr = MediaManager::GetIfExists(); |
426 | 0 | if (!mgr) { |
427 | 0 | return false; |
428 | 0 | } |
429 | 0 | RefPtr<Pledge<nsCString>> pledge = mgr->mGetPrincipalKeyPledges.Remove(aRequestId); |
430 | 0 | if (pledge) { |
431 | 0 | pledge->Resolve(aKey); |
432 | 0 | } |
433 | 0 | return true; |
434 | 0 | } |
435 | | |
436 | | template<class Super> mozilla::ipc::IPCResult |
437 | | Parent<Super>::RecvGetPrincipalKey(const uint32_t& aRequestId, |
438 | | const ipc::PrincipalInfo& aPrincipalInfo, |
439 | | const bool& aPersist) |
440 | 0 | { |
441 | 0 | MOZ_ASSERT(NS_IsMainThread()); |
442 | 0 |
|
443 | 0 | // First, get profile dir. |
444 | 0 |
|
445 | 0 | MOZ_ASSERT(NS_IsMainThread()); |
446 | 0 | nsCOMPtr<nsIFile> profileDir; |
447 | 0 | nsresult rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, |
448 | 0 | getter_AddRefs(profileDir)); |
449 | 0 | if (NS_WARN_IF(NS_FAILED(rv))) { |
450 | 0 | return IPCResult(this, false); |
451 | 0 | } |
452 | 0 | |
453 | 0 | // Then over to stream-transport thread (a thread pool) to do the actual |
454 | 0 | // file io. Stash a pledge to hold the answer and get an id for this request. |
455 | 0 | |
456 | 0 | RefPtr<Pledge<nsCString>> p = new Pledge<nsCString>(); |
457 | 0 | uint32_t id = mOutstandingPledges.Append(*p); |
458 | 0 |
|
459 | 0 | nsCOMPtr<nsIEventTarget> sts = do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID); |
460 | 0 | MOZ_ASSERT(sts); |
461 | 0 | RefPtr<Parent<Super>> that(this); |
462 | 0 |
|
463 | 0 | rv = sts->Dispatch(NewRunnableFrom([this, that, id, profileDir, |
464 | 0 | aPrincipalInfo, aPersist]() -> nsresult { |
465 | 0 | MOZ_ASSERT(!NS_IsMainThread()); |
466 | 0 | StaticMutexAutoLock lock(sOriginKeyStoreMutex); |
467 | 0 | if (!sOriginKeyStore) { |
468 | 0 | return NS_ERROR_FAILURE; |
469 | 0 | } |
470 | 0 | sOriginKeyStore->mOriginKeys.SetProfileDir(profileDir); |
471 | 0 |
|
472 | 0 | nsresult rv; |
473 | 0 | nsAutoCString result; |
474 | 0 | if (IsPincipalInfoPrivate(aPrincipalInfo)) { |
475 | 0 | rv = sOriginKeyStore->mPrivateBrowsingOriginKeys.GetPrincipalKey(aPrincipalInfo, result); |
476 | 0 | } else { |
477 | 0 | rv = sOriginKeyStore->mOriginKeys.GetPrincipalKey(aPrincipalInfo, result, aPersist); |
478 | 0 | } |
479 | 0 |
|
480 | 0 | if (NS_WARN_IF(NS_FAILED(rv))) { |
481 | 0 | return rv; |
482 | 0 | } |
483 | 0 | |
484 | 0 | // Pass result back to main thread. |
485 | 0 | rv = NS_DispatchToMainThread(NewRunnableFrom([this, that, id, |
486 | 0 | result]() -> nsresult { |
487 | 0 | if (mDestroyed) { |
488 | 0 | return NS_OK; |
489 | 0 | } |
490 | 0 | RefPtr<Pledge<nsCString>> p = mOutstandingPledges.Remove(id); |
491 | 0 | if (!p) { |
492 | 0 | return NS_ERROR_UNEXPECTED; |
493 | 0 | } |
494 | 0 | p->Resolve(result); |
495 | 0 | return NS_OK; |
496 | 0 | }), NS_DISPATCH_NORMAL); Unexecuted instantiation: mozilla::media::Parent<mozilla::media::PMediaParent>::RecvGetPrincipalKey(unsigned int const&, mozilla::ipc::PrincipalInfo const&, bool const&)::{lambda()#1}::operator()() const::{lambda()#1}::operator()() const Unexecuted instantiation: mozilla::media::Parent<mozilla::media::NonE10s>::RecvGetPrincipalKey(unsigned int const&, mozilla::ipc::PrincipalInfo const&, bool const&)::{lambda()#1}::operator()() const::{lambda()#1}::operator()() const |
497 | 0 |
|
498 | 0 | if (NS_WARN_IF(NS_FAILED(rv))) { |
499 | 0 | return rv; |
500 | 0 | } |
501 | 0 | return NS_OK; |
502 | 0 | }), NS_DISPATCH_NORMAL); Unexecuted instantiation: mozilla::media::Parent<mozilla::media::PMediaParent>::RecvGetPrincipalKey(unsigned int const&, mozilla::ipc::PrincipalInfo const&, bool const&)::{lambda()#1}::operator()() const Unexecuted instantiation: mozilla::media::Parent<mozilla::media::NonE10s>::RecvGetPrincipalKey(unsigned int const&, mozilla::ipc::PrincipalInfo const&, bool const&)::{lambda()#1}::operator()() const |
503 | 0 |
|
504 | 0 | if (NS_WARN_IF(NS_FAILED(rv))) { |
505 | 0 | return IPCResult(this, false); |
506 | 0 | } |
507 | 0 | p->Then([this, that, aRequestId](const nsCString& aKey) mutable { |
508 | 0 | if (mDestroyed) { |
509 | 0 | return NS_OK; |
510 | 0 | } |
511 | 0 | Unused << this->SendGetPrincipalKeyResponse(aRequestId, aKey); |
512 | 0 | return NS_OK; |
513 | 0 | }); Unexecuted instantiation: mozilla::media::Parent<mozilla::media::PMediaParent>::RecvGetPrincipalKey(unsigned int const&, mozilla::ipc::PrincipalInfo const&, bool const&)::{lambda(nsTString<char> const&)#1}::operator()(nsTString<char> const&) Unexecuted instantiation: mozilla::media::Parent<mozilla::media::NonE10s>::RecvGetPrincipalKey(unsigned int const&, mozilla::ipc::PrincipalInfo const&, bool const&)::{lambda(nsTString<char> const&)#1}::operator()(nsTString<char> const&) |
514 | 0 | return IPC_OK(); |
515 | 0 | } Unexecuted instantiation: mozilla::media::Parent<mozilla::media::NonE10s>::RecvGetPrincipalKey(unsigned int const&, mozilla::ipc::PrincipalInfo const&, bool const&) Unexecuted instantiation: mozilla::media::Parent<mozilla::media::PMediaParent>::RecvGetPrincipalKey(unsigned int const&, mozilla::ipc::PrincipalInfo const&, bool const&) |
516 | | |
517 | | template<class Super> mozilla::ipc::IPCResult |
518 | | Parent<Super>::RecvSanitizeOriginKeys(const uint64_t& aSinceWhen, |
519 | | const bool& aOnlyPrivateBrowsing) |
520 | 0 | { |
521 | 0 | MOZ_ASSERT(NS_IsMainThread()); |
522 | 0 | nsCOMPtr<nsIFile> profileDir; |
523 | 0 | nsresult rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, |
524 | 0 | getter_AddRefs(profileDir)); |
525 | 0 | if (NS_WARN_IF(NS_FAILED(rv))) { |
526 | 0 | return IPCResult(this, false); |
527 | 0 | } |
528 | 0 | // Over to stream-transport thread (a thread pool) to do the file io. |
529 | 0 | |
530 | 0 | nsCOMPtr<nsIEventTarget> sts = do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID); |
531 | 0 | MOZ_ASSERT(sts); |
532 | 0 |
|
533 | 0 | rv = sts->Dispatch(NewRunnableFrom([profileDir, aSinceWhen, |
534 | 0 | aOnlyPrivateBrowsing]() -> nsresult { |
535 | 0 | MOZ_ASSERT(!NS_IsMainThread()); |
536 | 0 | StaticMutexAutoLock lock(sOriginKeyStoreMutex); |
537 | 0 | if (!sOriginKeyStore) { |
538 | 0 | return NS_ERROR_FAILURE; |
539 | 0 | } |
540 | 0 | sOriginKeyStore->mPrivateBrowsingOriginKeys.Clear(aSinceWhen); |
541 | 0 | if (!aOnlyPrivateBrowsing) { |
542 | 0 | sOriginKeyStore->mOriginKeys.SetProfileDir(profileDir); |
543 | 0 | sOriginKeyStore->mOriginKeys.Clear(aSinceWhen); |
544 | 0 | } |
545 | 0 | return NS_OK; |
546 | 0 | }), NS_DISPATCH_NORMAL); Unexecuted instantiation: mozilla::media::Parent<mozilla::media::PMediaParent>::RecvSanitizeOriginKeys(unsigned long const&, bool const&)::{lambda()#1}::operator()() const Unexecuted instantiation: mozilla::media::Parent<mozilla::media::NonE10s>::RecvSanitizeOriginKeys(unsigned long const&, bool const&)::{lambda()#1}::operator()() const |
547 | 0 | if (NS_WARN_IF(NS_FAILED(rv))) { |
548 | 0 | return IPCResult(this, false); |
549 | 0 | } |
550 | 0 | return IPC_OK(); |
551 | 0 | } Unexecuted instantiation: mozilla::media::Parent<mozilla::media::NonE10s>::RecvSanitizeOriginKeys(unsigned long const&, bool const&) Unexecuted instantiation: mozilla::media::Parent<mozilla::media::PMediaParent>::RecvSanitizeOriginKeys(unsigned long const&, bool const&) |
552 | | |
553 | | template<class Super> void |
554 | | Parent<Super>::ActorDestroy(ActorDestroyReason aWhy) |
555 | 0 | { |
556 | 0 | // No more IPC from here |
557 | 0 | mDestroyed = true; |
558 | 0 | LOG((__FUNCTION__)); |
559 | 0 | } Unexecuted instantiation: mozilla::media::Parent<mozilla::media::NonE10s>::ActorDestroy(mozilla::ipc::IProtocol::ActorDestroyReason) Unexecuted instantiation: mozilla::media::Parent<mozilla::media::PMediaParent>::ActorDestroy(mozilla::ipc::IProtocol::ActorDestroyReason) |
560 | | |
561 | | template<class Super> |
562 | | Parent<Super>::Parent() |
563 | | : mOriginKeyStore(OriginKeyStore::Get()) |
564 | | , mDestroyed(false) |
565 | 0 | { |
566 | 0 | LOG(("media::Parent: %p", this)); |
567 | 0 | } Unexecuted instantiation: mozilla::media::Parent<mozilla::media::NonE10s>::Parent() Unexecuted instantiation: mozilla::media::Parent<mozilla::media::PMediaParent>::Parent() |
568 | | |
569 | | template<class Super> |
570 | | Parent<Super>::~Parent() |
571 | 0 | { |
572 | 0 | LOG(("~media::Parent: %p", this)); |
573 | 0 | } Unexecuted instantiation: mozilla::media::Parent<mozilla::media::NonE10s>::~Parent() Unexecuted instantiation: mozilla::media::Parent<mozilla::media::PMediaParent>::~Parent() |
574 | | |
575 | | PMediaParent* |
576 | | AllocPMediaParent() |
577 | 0 | { |
578 | 0 | Parent<PMediaParent>* obj = new Parent<PMediaParent>(); |
579 | 0 | obj->AddRef(); |
580 | 0 | return obj; |
581 | 0 | } |
582 | | |
583 | | bool |
584 | | DeallocPMediaParent(media::PMediaParent *aActor) |
585 | 0 | { |
586 | 0 | static_cast<Parent<PMediaParent>*>(aActor)->Release(); |
587 | 0 | return true; |
588 | 0 | } |
589 | | |
590 | | } // namespace media |
591 | | } // namespace mozilla |
592 | | |
593 | | // Instantiate templates to satisfy linker |
594 | | template class mozilla::media::Parent<mozilla::media::NonE10s>; |