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

Side by Side Diff: third_party/WebKit/Source/platform/exported/Platform.cpp

Issue 1660383002: Refactoring: Move some classes from content/child to platform (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add PLATFORM_EXPORT; Address haraken's review Created 4 years, 10 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) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 10 matching lines...) Expand all
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
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 "base/thread_task_runner_handle.h"
32 #include "base/trace_event/memory_dump_manager.h"
31 #include "platform/PartitionAllocMemoryDumpProvider.h" 33 #include "platform/PartitionAllocMemoryDumpProvider.h"
32 #include "platform/graphics/CompositorFactory.h" 34 #include "platform/graphics/CompositorFactory.h"
35 #include "platform/web_memory_dump_provider_adapter.h"
33 #include "public/platform/Platform.h" 36 #include "public/platform/Platform.h"
37 #include "wtf/HashMap.h"
38 #include "wtf/OwnPtr.h"
34 39
35 namespace blink { 40 namespace blink {
36 41
37 static Platform* s_platform = 0; 42 static Platform* s_platform = 0;
43 using ProviderToAdapterMap = HashMap<WebMemoryDumpProvider*, OwnPtr<WebMemoryDum pProviderAdapter>>;
44
45 namespace {
46
47 ProviderToAdapterMap& memoryDumpProviders()
48 {
49 DEFINE_STATIC_LOCAL(ProviderToAdapterMap, providerToAdapterMap, ());
50 return providerToAdapterMap;
51 }
52
53 } // namespace
38 54
39 Platform::Platform() 55 Platform::Platform()
40 : m_mainThread(0) 56 : m_mainThread(0)
41 { 57 {
42 } 58 }
43 59
44 void Platform::initialize(Platform* platform) 60 void Platform::initialize(Platform* platform)
45 { 61 {
46 s_platform = platform; 62 s_platform = platform;
47 if (s_platform) 63 if (s_platform)
(...skipping 21 matching lines...) Expand all
69 Platform* Platform::current() 85 Platform* Platform::current()
70 { 86 {
71 return s_platform; 87 return s_platform;
72 } 88 }
73 89
74 WebThread* Platform::mainThread() const 90 WebThread* Platform::mainThread() const
75 { 91 {
76 return m_mainThread; 92 return m_mainThread;
77 } 93 }
78 94
95 void Platform::registerMemoryDumpProvider(WebMemoryDumpProvider* provider, const char* name)
96 {
97 WebMemoryDumpProviderAdapter* adapter = new WebMemoryDumpProviderAdapter(pro vider);
98 ProviderToAdapterMap::AddResult result = memoryDumpProviders().add(provider, adoptPtr(adapter));
99 if (!result.isNewEntry)
100 return;
101 adapter->set_is_registered(true);
102 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(ad apter, name, base::ThreadTaskRunnerHandle::Get());
103 }
104
105 void Platform::unregisterMemoryDumpProvider(WebMemoryDumpProvider* provider)
106 {
107 ProviderToAdapterMap::iterator it = memoryDumpProviders().find(provider);
108 if (it == memoryDumpProviders().end())
109 return;
110 WebMemoryDumpProviderAdapter* adapter = it->value.get();
111 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider( adapter);
112 adapter->set_is_registered(false);
113 memoryDumpProviders().remove(it);
114 }
115
79 } // namespace blink 116 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698