OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "extensions/renderer/worker_script_context_set.h" | 5 #include "extensions/renderer/worker_script_context_set.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "extensions/renderer/script_context.h" | 10 #include "extensions/renderer/script_context.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 }; | 26 }; |
27 return std::find_if(contexts->begin(), contexts->end(), context_matches); | 27 return std::find_if(contexts->begin(), contexts->end(), context_matches); |
28 } | 28 } |
29 | 29 |
30 } // namespace | 30 } // namespace |
31 | 31 |
32 WorkerScriptContextSet::WorkerScriptContextSet() {} | 32 WorkerScriptContextSet::WorkerScriptContextSet() {} |
33 | 33 |
34 WorkerScriptContextSet::~WorkerScriptContextSet() {} | 34 WorkerScriptContextSet::~WorkerScriptContextSet() {} |
35 | 35 |
36 void WorkerScriptContextSet::Insert(scoped_ptr<ScriptContext> context) { | 36 void WorkerScriptContextSet::Insert(std::unique_ptr<ScriptContext> context) { |
37 DCHECK_GT(content::WorkerThread::GetCurrentId(), 0) | 37 DCHECK_GT(content::WorkerThread::GetCurrentId(), 0) |
38 << "Must be called on a worker thread"; | 38 << "Must be called on a worker thread"; |
39 ContextVector* contexts = contexts_tls_.Get(); | 39 ContextVector* contexts = contexts_tls_.Get(); |
40 if (!contexts) { | 40 if (!contexts) { |
41 // First context added for this thread. Create a new set, then wait for | 41 // First context added for this thread. Create a new set, then wait for |
42 // this thread's shutdown. | 42 // this thread's shutdown. |
43 contexts = new ContextVector(); | 43 contexts = new ContextVector(); |
44 contexts_tls_.Set(contexts); | 44 contexts_tls_.Set(contexts); |
45 content::WorkerThread::AddObserver(this); | 45 content::WorkerThread::AddObserver(this); |
46 } | 46 } |
(...skipping 26 matching lines...) Expand all Loading... |
73 content::WorkerThread::RemoveObserver(this); | 73 content::WorkerThread::RemoveObserver(this); |
74 ContextVector* contexts = contexts_tls_.Get(); | 74 ContextVector* contexts = contexts_tls_.Get(); |
75 DCHECK(contexts); | 75 DCHECK(contexts); |
76 for (ScriptContext* context : *contexts) | 76 for (ScriptContext* context : *contexts) |
77 context->Invalidate(); | 77 context->Invalidate(); |
78 contexts_tls_.Set(nullptr); | 78 contexts_tls_.Set(nullptr); |
79 delete contexts; | 79 delete contexts; |
80 } | 80 } |
81 | 81 |
82 } // namespace extensions | 82 } // namespace extensions |
OLD | NEW |