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

Side by Side Diff: sky/engine/platform/SharedBuffer.cpp

Issue 691493004: Remove callOnMainThread (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « no previous file | sky/engine/platform/testing/RunAllTests.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. 3 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the 11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution. 12 * documentation and/or other materials provided with the distribution.
13 * 13 *
14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */ 25 */
26 26
27 #include "config.h" 27 #include "config.h"
28 #include "platform/SharedBuffer.h" 28 #include "platform/SharedBuffer.h"
29 29
30 #include "base/bind.h"
31 #include "public/platform/Platform.h"
30 #include "wtf/unicode/Unicode.h" 32 #include "wtf/unicode/Unicode.h"
31 #include "wtf/unicode/UTF8.h" 33 #include "wtf/unicode/UTF8.h"
32 34
33 #undef SHARED_BUFFER_STATS 35 #undef SHARED_BUFFER_STATS
34 36
35 #ifdef SHARED_BUFFER_STATS 37 #ifdef SHARED_BUFFER_STATS
36 #include "wtf/DataLog.h" 38 #include "wtf/DataLog.h"
37 #include "wtf/MainThread.h"
38 #endif 39 #endif
39 40
40 namespace blink { 41 namespace blink {
41 42
42 static const unsigned segmentSize = 0x1000; 43 static const unsigned segmentSize = 0x1000;
43 static const unsigned segmentPositionMask = 0x0FFF; 44 static const unsigned segmentPositionMask = 0x0FFF;
44 45
45 static inline unsigned segmentIndex(unsigned position) 46 static inline unsigned segmentIndex(unsigned position)
46 { 47 {
47 return position / segmentSize; 48 return position / segmentSize;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 } 100 }
100 101
101 for (unsigned i = 0; i < snippetLength; ++i) { 102 for (unsigned i = 0; i < snippetLength; ++i) {
102 if (!isASCIIPrintable(snippet[i])) 103 if (!isASCIIPrintable(snippet[i]))
103 snippet[i] = '?'; 104 snippet[i] = '?';
104 } 105 }
105 106
106 return result; 107 return result;
107 } 108 }
108 109
109 static void printStats(void*) 110 static void printStats()
110 { 111 {
111 MutexLocker locker(statsMutex()); 112 MutexLocker locker(statsMutex());
112 Vector<SharedBuffer*> buffers; 113 Vector<SharedBuffer*> buffers;
113 for (HashSet<SharedBuffer*>::const_iterator iter = liveBuffers().begin(); it er != liveBuffers().end(); ++iter) 114 for (HashSet<SharedBuffer*>::const_iterator iter = liveBuffers().begin(); it er != liveBuffers().end(); ++iter)
114 buffers.append(*iter); 115 buffers.append(*iter);
115 std::sort(buffers.begin(), buffers.end(), sizeComparator); 116 std::sort(buffers.begin(), buffers.end(), sizeComparator);
116 117
117 dataLogF("---- Shared Buffer Stats ----\n"); 118 dataLogF("---- Shared Buffer Stats ----\n");
118 for (size_t i = 0; i < buffers.size() && i < 64; ++i) { 119 for (size_t i = 0; i < buffers.size() && i < 64; ++i) {
119 CString snippet = snippetForBuffer(buffers[i]); 120 CString snippet = snippetForBuffer(buffers[i]);
120 dataLogF("Buffer size=%8u %s\n", buffers[i]->size(), snippet.data()); 121 dataLogF("Buffer size=%8u %s\n", buffers[i]->size(), snippet.data());
121 } 122 }
122 } 123 }
123 124
124 static void didCreateSharedBuffer(SharedBuffer* buffer) 125 static void didCreateSharedBuffer(SharedBuffer* buffer)
125 { 126 {
126 MutexLocker locker(statsMutex()); 127 MutexLocker locker(statsMutex());
127 liveBuffers().add(buffer); 128 liveBuffers().add(buffer);
128 129
129 callOnMainThread(printStats, 0); 130 Platform::current()->mainThreadTaskRunner()->PostTask(FROM_HERE, base::Bind( &printStats));
130 } 131 }
131 132
132 static void willDestroySharedBuffer(SharedBuffer* buffer) 133 static void willDestroySharedBuffer(SharedBuffer* buffer)
133 { 134 {
134 MutexLocker locker(statsMutex()); 135 MutexLocker locker(statsMutex());
135 liveBuffers().remove(buffer); 136 liveBuffers().remove(buffer);
136 } 137 }
137 138
138 #endif 139 #endif
139 140
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 mergeSegmentsIntoBuffer(); 413 mergeSegmentsIntoBuffer();
413 m_buffer.unlock(); 414 m_buffer.unlock();
414 } 415 }
415 416
416 bool SharedBuffer::isLocked() const 417 bool SharedBuffer::isLocked() const
417 { 418 {
418 return m_buffer.isLocked(); 419 return m_buffer.isLocked();
419 } 420 }
420 421
421 } // namespace blink 422 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | sky/engine/platform/testing/RunAllTests.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698