OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/public/browser/browser_context.h" | 5 #include "content/public/browser/browser_context.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 base::Bind(ShutdownServiceWorkerContext)); | 361 base::Bind(ShutdownServiceWorkerContext)); |
362 | 362 |
363 // Shared workers also keep render process hosts alive, and are expected to | 363 // Shared workers also keep render process hosts alive, and are expected to |
364 // return ref counts to 0 after documents close. However, shared worker | 364 // return ref counts to 0 after documents close. However, shared worker |
365 // bookkeeping is done on the IO thread and we want to ensure the hosts are | 365 // bookkeeping is done on the IO thread and we want to ensure the hosts are |
366 // destructed now, so forcibly release their ref counts here. | 366 // destructed now, so forcibly release their ref counts here. |
367 for (RenderProcessHost::iterator host_iterator = | 367 for (RenderProcessHost::iterator host_iterator = |
368 RenderProcessHost::AllHostsIterator(); | 368 RenderProcessHost::AllHostsIterator(); |
369 !host_iterator.IsAtEnd(); host_iterator.Advance()) { | 369 !host_iterator.IsAtEnd(); host_iterator.Advance()) { |
370 RenderProcessHost* host = host_iterator.GetCurrentValue(); | 370 RenderProcessHost* host = host_iterator.GetCurrentValue(); |
371 if (host->GetBrowserContext() == browser_context) | 371 if (host->GetBrowserContext() == browser_context) { |
| 372 // This will also clean up spare RPH references. |
372 host->ForceReleaseWorkerRefCounts(); | 373 host->ForceReleaseWorkerRefCounts(); |
| 374 } |
373 } | 375 } |
374 } | 376 } |
375 | 377 |
376 void BrowserContext::EnsureResourceContextInitialized(BrowserContext* context) { | 378 void BrowserContext::EnsureResourceContextInitialized(BrowserContext* context) { |
377 // This will be enough to tickle initialization of BrowserContext if | 379 // This will be enough to tickle initialization of BrowserContext if |
378 // necessary, which initializes ResourceContext. The reason we don't call | 380 // necessary, which initializes ResourceContext. The reason we don't call |
379 // ResourceContext::InitializeResourceContext() directly here is that | 381 // ResourceContext::InitializeResourceContext() directly here is that |
380 // ResourceContext initialization may call back into BrowserContext | 382 // ResourceContext initialization may call back into BrowserContext |
381 // and when that call returns it'll end rewriting its UserData map. It will | 383 // and when that call returns it'll end rewriting its UserData map. It will |
382 // end up rewriting the same value but this still causes a race condition. | 384 // end up rewriting the same value but this still causes a race condition. |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 | 564 |
563 // static | 565 // static |
564 std::string BrowserContext::CreateRandomMediaDeviceIDSalt() { | 566 std::string BrowserContext::CreateRandomMediaDeviceIDSalt() { |
565 std::string salt; | 567 std::string salt; |
566 base::Base64Encode(base::RandBytesAsString(16), &salt); | 568 base::Base64Encode(base::RandBytesAsString(16), &salt); |
567 DCHECK(!salt.empty()); | 569 DCHECK(!salt.empty()); |
568 return salt; | 570 return salt; |
569 } | 571 } |
570 | 572 |
571 } // namespace content | 573 } // namespace content |
OLD | NEW |