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

Side by Side Diff: sky/engine/core/inspector/ConsoleMessageStorage.cpp

Issue 922893002: Merge the Sky Engine changes from the SkyDart branch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 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
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "sky/engine/config.h"
6 #include "sky/engine/core/inspector/ConsoleMessageStorage.h"
7
8 #include "sky/engine/core/dom/Document.h"
9 #include "sky/engine/core/frame/LocalDOMWindow.h"
10 #include "sky/engine/core/frame/LocalFrame.h"
11 #include "sky/engine/core/inspector/ConsoleMessage.h"
12
13 namespace blink {
14
15 static const unsigned maxConsoleMessageCount = 1000;
16
17 ConsoleMessageStorage::ConsoleMessageStorage(ExecutionContext* context)
18 : m_expiredCount(0)
19 , m_context(context)
20 , m_frame(nullptr)
21 {
22 }
23
24 ConsoleMessageStorage::ConsoleMessageStorage(LocalFrame* frame)
25 : m_expiredCount(0)
26 , m_context(nullptr)
27 , m_frame(frame)
28 {
29 }
30
31 void ConsoleMessageStorage::reportMessage(PassRefPtr<ConsoleMessage> prpMessage)
32 {
33 RefPtr<ConsoleMessage> message = prpMessage;
34 message->collectCallStack();
35
36 if (message->type() == ClearMessageType)
37 clear();
38
39 ASSERT(m_messages.size() <= maxConsoleMessageCount);
40 if (m_messages.size() == maxConsoleMessageCount) {
41 ++m_expiredCount;
42 m_messages.removeFirst();
43 }
44 m_messages.append(message);
45 }
46
47 void ConsoleMessageStorage::clear()
48 {
49 m_messages.clear();
50 m_expiredCount = 0;
51 }
52
53 Vector<unsigned> ConsoleMessageStorage::argumentCounts() const
54 {
55 Vector<unsigned> result(m_messages.size());
56 for (size_t i = 0; i < m_messages.size(); ++i)
57 result[i] = m_messages[i]->argumentCount();
58 return result;
59 }
60
61 void ConsoleMessageStorage::frameWindowDiscarded(LocalDOMWindow* window)
62 {
63 for (size_t i = 0; i < m_messages.size(); ++i)
64 m_messages[i]->frameWindowDiscarded(window);
65 }
66
67 size_t ConsoleMessageStorage::size() const
68 {
69 return m_messages.size();
70 }
71
72 ConsoleMessage* ConsoleMessageStorage::at(size_t index) const
73 {
74 return m_messages[index].get();
75 }
76
77 int ConsoleMessageStorage::expiredCount() const
78 {
79 return m_expiredCount;
80 }
81
82 ExecutionContext* ConsoleMessageStorage::executionContext() const
83 {
84 return m_frame ? m_frame->document() : m_context;
85 }
86
87 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/inspector/ConsoleMessageStorage.h ('k') | sky/engine/core/inspector/InjectedScriptHost.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698