Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright (C) 2014 Google Inc. All rights reserved. | |
| 3 * | |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions are | |
| 6 * met: | |
| 7 * | |
| 8 * * Redistributions of source code must retain the above copyright | |
| 9 * notice, this list of conditions and the following disclaimer. | |
| 10 * * Redistributions in binary form must reproduce the above | |
| 11 * copyright notice, this list of conditions and the following disclaimer | |
| 12 * in the documentation and/or other materials provided with the | |
| 13 * distribution. | |
| 14 * * Neither the name of Google Inc. nor the names of its | |
| 15 * contributors may be used to endorse or promote products derived from | |
| 16 * this software without specific prior written permission. | |
| 17 * | |
| 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 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. | |
| 29 */ | |
| 30 | |
| 31 #include "config.h" | |
| 32 #include "core/inspector/PromiseOfficer.h" | |
| 33 | |
| 34 namespace WebCore { | |
| 35 | |
| 36 void PromiseOfficer::addPromise(ExecutionContext* context, v8::Handle<v8::Object > promise, v8::Handle<v8::Object> parentPromise, V8PromiseCustom::PromiseState s tate) { | |
|
aandrey
2014/02/26 16:11:30
style: "{" on new line
Alexandra Mikhaylova
2014/02/28 13:52:05
Done.
| |
| 37 int promiseHash = promise->GetIdentityHash(); | |
| 38 PromiseDataMap::iterator it = m_promiseDataMap.find(promiseHash); | |
| 39 if (it != m_promiseDataMap.end()) { | |
| 40 PromiseDataVector& vector = it->value; | |
| 41 for (size_t index = 0; index < vector.size(); index++) { | |
|
aandrey
2014/02/26 16:11:30
remove or guard with "#ifndef NDEBUG"
Alexandra Mikhaylova
2014/02/28 13:52:05
Done.
| |
| 42 RefPtr<PromiseData> data = vector.at(index); | |
| 43 ASSERT(data->getPromise() != promise); // Because we add a new promi se (and don't update existing ones). | |
| 44 } | |
| 45 vector.append(adoptRef(new PromiseData(promise, parentPromise, v8::Undef ined(toIsolate(context)), state, context))); | |
| 46 } else { | |
| 47 PromiseDataVector vector; | |
| 48 vector.append(adoptRef(new PromiseData(promise, parentPromise, v8::Undef ined(toIsolate(context)), state, context))); | |
|
aandrey
2014/02/26 16:11:30
we can remove code dup:
PromiseDataVector* vector
Alexandra Mikhaylova
2014/02/28 13:52:05
Done.
| |
| 49 m_promiseDataMap.set(promiseHash, vector); | |
| 50 } | |
| 51 } | |
| 52 | |
| 53 void PromiseOfficer::setPromiseParent(ExecutionContext* context, v8::Handle<v8:: Object> promise, v8::Handle<v8::Object> parentPromise) { | |
| 54 int promiseHash = promise->GetIdentityHash(); | |
| 55 PromiseDataMap::iterator it = m_promiseDataMap.find(promiseHash); | |
| 56 ASSERT(it != m_promiseDataMap.end()); // This must be a promise that's alrea dy been tracked. | |
|
aandrey
2014/02/26 16:11:30
we may be activated after a web page was loaded
Alexandra Mikhaylova
2014/02/28 13:52:05
Done, removed ASSERT.
| |
| 57 PromiseDataVector& vector = it->value; | |
| 58 for (size_t index = 0; index < vector.size(); index++) { | |
| 59 RefPtr<PromiseData> data = vector.at(index); | |
| 60 if (data->getPromise() == promise && data->getParentPromise() != parentP romise) { | |
|
aandrey
2014/02/26 16:11:30
remove: data->getParentPromise() != parentPromise
Alexandra Mikhaylova
2014/02/28 13:52:05
Done.
| |
| 61 vector.remove(index); | |
| 62 vector.append(adoptRef(new PromiseData(promise, parentPromise, data- >getResult(), data->getState(), context))); | |
|
aandrey
2014/02/26 16:11:30
just update the parent
Alexandra Mikhaylova
2014/02/28 13:52:05
Done.
| |
| 63 break; | |
| 64 } | |
| 65 } | |
| 66 } | |
| 67 | |
| 68 void PromiseOfficer::setPromiseStateAndResult(ExecutionContext* context, v8::Han dle<v8::Object> promise, v8::Handle<v8::Value> result, V8PromiseCustom::PromiseS tate state) { | |
| 69 int promiseHash = promise->GetIdentityHash(); | |
| 70 PromiseDataMap::iterator it = m_promiseDataMap.find(promiseHash); | |
| 71 ASSERT(it != m_promiseDataMap.end()); // This must be a promise that's alrea dy been tracked. | |
|
aandrey
2014/02/26 16:11:30
ditto
Alexandra Mikhaylova
2014/02/28 13:52:05
Done.
| |
| 72 PromiseDataVector& vector = it->value; | |
| 73 for (size_t index = 0; index < vector.size(); index++) { | |
| 74 RefPtr<PromiseData> data = vector.at(index); | |
| 75 if (data->getPromise() == promise && data->getState() != state) { | |
|
aandrey
2014/02/26 16:11:30
remove: data->getState() != state
Alexandra Mikhaylova
2014/02/28 13:52:05
Done.
| |
| 76 vector.remove(index); | |
| 77 vector.append(adoptRef(new PromiseData(promise, data->getParentPromi se(), result, state, context))); | |
|
aandrey
2014/02/26 16:11:30
just update
Alexandra Mikhaylova
2014/02/28 13:52:05
Done.
| |
| 78 break; | |
| 79 } | |
| 80 } | |
| 81 } | |
| 82 | |
| 83 } // namespace WebCore | |
| OLD | NEW |