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

Side by Side Diff: Source/core/inspector/InjectedScriptManager.cpp

Issue 800113002: Use C++11 range-based for loop in Source/core/inspector (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase again and again! Created 6 years 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 | « Source/core/inspector/DOMPatchSupport.cpp ('k') | Source/core/inspector/InspectorCSSAgent.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) 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> 3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com>
4 * Copyright (C) 2012 Google Inc. All rights reserved. 4 * Copyright (C) 2012 Google Inc. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 InjectedScriptHost* InjectedScriptManager::injectedScriptHost() 78 InjectedScriptHost* InjectedScriptManager::injectedScriptHost()
79 { 79 {
80 return m_injectedScriptHost.get(); 80 return m_injectedScriptHost.get();
81 } 81 }
82 82
83 InjectedScript InjectedScriptManager::injectedScriptForId(int id) 83 InjectedScript InjectedScriptManager::injectedScriptForId(int id)
84 { 84 {
85 IdToInjectedScriptMap::iterator it = m_idToInjectedScript.find(id); 85 IdToInjectedScriptMap::iterator it = m_idToInjectedScript.find(id);
86 if (it != m_idToInjectedScript.end()) 86 if (it != m_idToInjectedScript.end())
87 return it->value; 87 return it->value;
88 for (ScriptStateToId::iterator it = m_scriptStateToId.begin(); it != m_scrip tStateToId.end(); ++it) { 88 for (auto& state : m_scriptStateToId) {
89 if (it->value == id) 89 if (state.value == id)
90 return injectedScriptFor(it->key.get()); 90 return injectedScriptFor(state.key.get());
91 } 91 }
92 return InjectedScript(); 92 return InjectedScript();
93 } 93 }
94 94
95 int InjectedScriptManager::injectedScriptIdFor(ScriptState* scriptState) 95 int InjectedScriptManager::injectedScriptIdFor(ScriptState* scriptState)
96 { 96 {
97 ScriptStateToId::iterator it = m_scriptStateToId.find(scriptState); 97 ScriptStateToId::iterator it = m_scriptStateToId.find(scriptState);
98 if (it != m_scriptStateToId.end()) 98 if (it != m_scriptStateToId.end())
99 return it->value; 99 return it->value;
100 int id = m_nextInjectedScriptId++; 100 int id = m_nextInjectedScriptId++;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 132
133 bool InjectedScriptManager::canAccessInspectedWorkerGlobalScope(ScriptState*) 133 bool InjectedScriptManager::canAccessInspectedWorkerGlobalScope(ScriptState*)
134 { 134 {
135 return true; 135 return true;
136 } 136 }
137 137
138 void InjectedScriptManager::releaseObjectGroup(const String& objectGroup) 138 void InjectedScriptManager::releaseObjectGroup(const String& objectGroup)
139 { 139 {
140 Vector<int> keys; 140 Vector<int> keys;
141 keys.appendRange(m_idToInjectedScript.keys().begin(), m_idToInjectedScript.k eys().end()); 141 keys.appendRange(m_idToInjectedScript.keys().begin(), m_idToInjectedScript.k eys().end());
142 for (Vector<int>::iterator k = keys.begin(); k != keys.end(); ++k) { 142 for (auto& key : keys) {
143 IdToInjectedScriptMap::iterator s = m_idToInjectedScript.find(*k); 143 IdToInjectedScriptMap::iterator s = m_idToInjectedScript.find(key);
144 if (s != m_idToInjectedScript.end()) 144 if (s != m_idToInjectedScript.end())
145 s->value.releaseObjectGroup(objectGroup); // m_idToInjectedScript ma y change here. 145 s->value.releaseObjectGroup(objectGroup); // m_idToInjectedScript ma y change here.
146 } 146 }
147 } 147 }
148 148
149 void InjectedScriptManager::setCustomObjectFormatterEnabled(bool enabled) 149 void InjectedScriptManager::setCustomObjectFormatterEnabled(bool enabled)
150 { 150 {
151 m_customObjectFormatterEnabled = enabled; 151 m_customObjectFormatterEnabled = enabled;
152 IdToInjectedScriptMap::iterator end = m_idToInjectedScript.end(); 152 IdToInjectedScriptMap::iterator end = m_idToInjectedScript.end();
153 for (IdToInjectedScriptMap::iterator it = m_idToInjectedScript.begin(); it ! = end; ++it) { 153 for (IdToInjectedScriptMap::iterator it = m_idToInjectedScript.begin(); it ! = end; ++it) {
(...skipping 24 matching lines...) Expand all
178 ScriptValue injectedScriptValue = createInjectedScript(injectedScriptSource( ), inspectedScriptState, id); 178 ScriptValue injectedScriptValue = createInjectedScript(injectedScriptSource( ), inspectedScriptState, id);
179 InjectedScript result(injectedScriptValue, m_inspectedStateAccessCheck); 179 InjectedScript result(injectedScriptValue, m_inspectedStateAccessCheck);
180 if (m_customObjectFormatterEnabled) 180 if (m_customObjectFormatterEnabled)
181 result.setCustomObjectFormatterEnabled(m_customObjectFormatterEnabled); 181 result.setCustomObjectFormatterEnabled(m_customObjectFormatterEnabled);
182 m_idToInjectedScript.set(id, result); 182 m_idToInjectedScript.set(id, result);
183 return result; 183 return result;
184 } 184 }
185 185
186 } // namespace blink 186 } // namespace blink
187 187
OLDNEW
« no previous file with comments | « Source/core/inspector/DOMPatchSupport.cpp ('k') | Source/core/inspector/InspectorCSSAgent.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698