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

Side by Side Diff: Source/core/speech/SpeechInput.cpp

Issue 255983003: Oilpan: Move all supplements of Page, Document, and WorkerClients to the managed heap. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: using namespace WebCore Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/speech/SpeechInput.h ('k') | Source/core/speech/SpeechInputListener.h » ('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) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 , m_nextListenerId(1) 44 , m_nextListenerId(1)
45 { 45 {
46 m_client->setListener(this); 46 m_client->setListener(this);
47 } 47 }
48 48
49 SpeechInput::~SpeechInput() 49 SpeechInput::~SpeechInput()
50 { 50 {
51 m_client->setListener(0); 51 m_client->setListener(0);
52 } 52 }
53 53
54 PassOwnPtr<SpeechInput> SpeechInput::create(PassOwnPtr<SpeechInputClient> client ) 54 PassOwnPtrWillBeRawPtr<SpeechInput> SpeechInput::create(PassOwnPtr<SpeechInputCl ient> client)
55 { 55 {
56 return adoptPtr(new SpeechInput(client)); 56 return adoptPtrWillBeNoop(new SpeechInput(client));
57 } 57 }
58 58
59 int SpeechInput::registerListener(InputFieldSpeechButtonElement* listener) 59 int SpeechInput::registerListener(SpeechInputListener* listener)
60 { 60 {
61 #if defined(DEBUG) 61 #if defined(DEBUG)
62 // Check if already present. 62 // Check if already present.
63 for (HashMap<int, InputFieldSpeechButtonElement*>::iterator it = m_listeners .begin(); it != m_listeners.end(); ++it) 63 for (WillBeHeapHashMap<int, RawPtrWillBeWeakMember<SpeechInputListener> >::i terator it = m_listeners.begin(); it != m_listeners.end(); ++it)
64 ASSERT(it->value != listener); 64 ASSERT(it->value != listener);
65 #endif 65 #endif
66 66
67 m_listeners.add(m_nextListenerId, listener); 67 m_listeners.add(m_nextListenerId, listener);
68 return m_nextListenerId++; 68 return m_nextListenerId++;
69 } 69 }
70 70
71 void SpeechInput::unregisterListener(int listenerId) 71 void SpeechInput::unregisterListener(int listenerId)
72 { 72 {
73 if (m_listeners.contains(listenerId)) 73 if (m_listeners.contains(listenerId))
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 { 114 {
115 ASSERT(m_listeners.contains(listenerId)); 115 ASSERT(m_listeners.contains(listenerId));
116 m_client->cancelRecognition(listenerId); 116 m_client->cancelRecognition(listenerId);
117 } 117 }
118 118
119 const char* SpeechInput::supplementName() 119 const char* SpeechInput::supplementName()
120 { 120 {
121 return "SpeechInput"; 121 return "SpeechInput";
122 } 122 }
123 123
124 void SpeechInput::trace(Visitor* visitor)
125 {
126 visitor->registerWeakMembers<SpeechInput, &SpeechInput::clearWeakMembers>(th is);
127 }
128
124 void provideSpeechInputTo(Page& page, PassOwnPtr<SpeechInputClient> client) 129 void provideSpeechInputTo(Page& page, PassOwnPtr<SpeechInputClient> client)
125 { 130 {
126 SpeechInput::provideTo(page, SpeechInput::supplementName(), SpeechInput::cre ate(client)); 131 SpeechInput::provideTo(page, SpeechInput::supplementName(), SpeechInput::cre ate(client));
127 } 132 }
128 133
129 void SpeechInput::clearWeakMembers(Visitor* visitor) 134 void SpeechInput::clearWeakMembers(Visitor* visitor)
130 { 135 {
131 Vector<int> deadListenerIds; 136 Vector<int> deadListenerIds;
132 HashMap<int, InputFieldSpeechButtonElement*>::const_iterator end = m_listene rs.end(); 137 WillBeHeapHashMap<int, RawPtrWillBeWeakMember<SpeechInputListener> >::const_ iterator end = m_listeners.end();
133 for (HashMap<int, InputFieldSpeechButtonElement*>::const_iterator it = m_lis teners.begin(); it != end; ++it) { 138 for (WillBeHeapHashMap<int, RawPtrWillBeWeakMember<SpeechInputListener> >::c onst_iterator it = m_listeners.begin(); it != end; ++it) {
134 if (!visitor->isAlive(it->value)) { 139 if (!visitor->isAlive(it->value)) {
135 deadListenerIds.append(it->key); 140 deadListenerIds.append(it->key);
136 m_client->cancelRecognition(it->key); 141 m_client->cancelRecognition(it->key);
137 } 142 }
138 } 143 }
139 for (unsigned i = 0; i < deadListenerIds.size(); ++i) 144 for (unsigned i = 0; i < deadListenerIds.size(); ++i)
140 m_listeners.remove(deadListenerIds[i]); 145 m_listeners.remove(deadListenerIds[i]);
141 } 146 }
142 147
143 } // namespace WebCore 148 } // namespace WebCore
144 149
145 #endif // ENABLE(INPUT_SPEECH) 150 #endif // ENABLE(INPUT_SPEECH)
OLDNEW
« no previous file with comments | « Source/core/speech/SpeechInput.h ('k') | Source/core/speech/SpeechInputListener.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698