Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 11 matching lines...) Expand all Loading... | |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "modules/donottrack/NavigatorDoNotTrack.h" | |
| 33 | 32 |
| 34 #include "core/loader/FrameLoader.h" | 33 #include "modules/performance/WorkerContextPerformance.h" |
| 35 #include "core/loader/FrameLoaderClient.h" | 34 |
| 36 #include "core/page/Frame.h" | 35 #include "core/dom/ScriptExecutionContext.h" |
| 37 #include "core/page/Navigator.h" | 36 #include "core/workers/WorkerContext.h" |
| 38 #include "wtf/PassOwnPtr.h" | 37 #include "modules/performance/WorkerPerformance.h" |
| 39 | 38 |
| 40 namespace WebCore { | 39 namespace WebCore { |
| 41 | 40 |
| 42 NavigatorDoNotTrack::NavigatorDoNotTrack(Frame* frame) | 41 WorkerContextPerformance::WorkerContextPerformance(ScriptExecutionContext* conte xt) |
| 43 : DOMWindowProperty(frame) | 42 : m_context(context) |
|
abarth-chromium
2013/06/12 23:11:41
Why do you need to hold m_context?
James Simonsen
2013/06/13 00:01:36
Done.
| |
| 44 { | 43 { |
| 45 } | 44 } |
| 46 | 45 |
| 47 NavigatorDoNotTrack::~NavigatorDoNotTrack() | 46 WorkerContextPerformance::~WorkerContextPerformance() |
| 48 { | 47 { |
| 49 } | 48 } |
| 50 | 49 |
| 51 const char* NavigatorDoNotTrack::supplementName() | 50 const char* WorkerContextPerformance::supplementName() |
| 52 { | 51 { |
| 53 return "NavigatorDoNotTrack"; | 52 return "WorkerContextPerformance"; |
| 54 } | 53 } |
| 55 | 54 |
| 56 NavigatorDoNotTrack* NavigatorDoNotTrack::from(Navigator* navigator) | 55 WorkerContextPerformance* WorkerContextPerformance::from(ScriptExecutionContext* context) |
| 57 { | 56 { |
| 58 NavigatorDoNotTrack* supplement = static_cast<NavigatorDoNotTrack*>(Suppleme nt<Navigator>::from(navigator, supplementName())); | 57 WorkerContextPerformance* supplement = static_cast<WorkerContextPerformance* >(Supplement<ScriptExecutionContext>::from(context, supplementName())); |
| 59 if (!supplement) { | 58 if (!supplement) { |
| 60 supplement = new NavigatorDoNotTrack(navigator->frame()); | 59 supplement = new WorkerContextPerformance(context); |
| 61 provideTo(navigator, supplementName(), adoptPtr(supplement)); | 60 provideTo(context, supplementName(), adoptPtr(supplement)); |
| 62 } | 61 } |
| 63 return supplement; | 62 return supplement; |
| 64 } | 63 } |
| 65 | 64 |
| 66 String NavigatorDoNotTrack::doNotTrack(Navigator* navigator) | 65 WorkerPerformance* WorkerContextPerformance::performance(ScriptExecutionContext* context) |
| 67 { | 66 { |
| 68 return NavigatorDoNotTrack::from(navigator)->doNotTrack(); | 67 return from(context)->performance(); |
|
abarth-chromium
2013/06/12 23:11:41
You can just pass context in here.
James Simonsen
2013/06/13 00:01:36
Yep. Thanks.
| |
| 69 } | 68 } |
| 70 | 69 |
| 71 String NavigatorDoNotTrack::doNotTrack() | 70 WorkerPerformance* WorkerContextPerformance::performance() |
| 72 { | 71 { |
| 73 return frame() ? frame()->loader()->client()->doNotTrackValue() : String(); | 72 if (!m_performance) { |
| 73 ASSERT_WITH_SECURITY_IMPLICATION(m_context->isWorkerContext()); | |
| 74 WorkerContext* workerContext = static_cast<WorkerContext*>(m_context); | |
| 75 m_performance = WorkerPerformance::create(workerContext); | |
| 76 } | |
| 77 return m_performance.get(); | |
| 74 } | 78 } |
| 75 | 79 |
| 76 } // namespace WebCore | 80 } // namespace WebCore |
| OLD | NEW |