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

Side by Side Diff: chrome/renderer/extensions/automation_internal_custom_bindings.cc

Issue 2542943002: Generalized fix for serialization error/reset issues (Closed)
Patch Set: Created 4 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/renderer/extensions/automation_internal_custom_bindings.h" 5 #include "chrome/renderer/extensions/automation_internal_custom_bindings.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 1139 matching lines...) Expand 10 before | Expand all | Expand 10 after
1150 cache->owner = this; 1150 cache->owner = this;
1151 tree_id_to_tree_cache_map_.insert(std::make_pair(tree_id, cache)); 1151 tree_id_to_tree_cache_map_.insert(std::make_pair(tree_id, cache));
1152 axtree_to_tree_cache_map_.insert(std::make_pair(&cache->tree, cache)); 1152 axtree_to_tree_cache_map_.insert(std::make_pair(&cache->tree, cache));
1153 } else { 1153 } else {
1154 cache = iter->second; 1154 cache = iter->second;
1155 } 1155 }
1156 1156
1157 // Update the internal state whether it's the active profile or not. 1157 // Update the internal state whether it's the active profile or not.
1158 cache->location_offset = params.location_offset; 1158 cache->location_offset = params.location_offset;
1159 deleted_node_ids_.clear(); 1159 deleted_node_ids_.clear();
1160 v8::Isolate* isolate = GetIsolate();
1161 v8::HandleScope handle_scope(isolate);
1162 v8::Context::Scope context_scope(context()->v8_context());
1163 v8::Local<v8::Array> args(v8::Array::New(GetIsolate(), 1U));
1160 if (!cache->tree.Unserialize(params.update)) { 1164 if (!cache->tree.Unserialize(params.update)) {
1161 LOG(ERROR) << cache->tree.error(); 1165 LOG(ERROR) << cache->tree.error();
1166 args->Set(0U, v8::Number::New(isolate, tree_id));
1167 context()->DispatchEvent(
1168 "automationInternal.onAccessibilityTreeSerializationError", args);
1162 return; 1169 return;
1163 } 1170 }
1164 1171
1165 // Don't send any events if it's not the active profile. 1172 // Don't send any events if it's not the active profile.
1166 if (!is_active_profile) 1173 if (!is_active_profile)
1167 return; 1174 return;
1168 1175
1169 SendNodesRemovedEvent(&cache->tree, deleted_node_ids_); 1176 SendNodesRemovedEvent(&cache->tree, deleted_node_ids_);
1170 deleted_node_ids_.clear(); 1177 deleted_node_ids_.clear();
1171 1178
1172 v8::Isolate* isolate = GetIsolate();
1173 v8::HandleScope handle_scope(isolate);
1174 v8::Context::Scope context_scope(context()->v8_context());
1175 v8::Local<v8::Array> args(v8::Array::New(GetIsolate(), 1U));
1176 v8::Local<v8::Object> event_params(v8::Object::New(GetIsolate())); 1179 v8::Local<v8::Object> event_params(v8::Object::New(GetIsolate()));
1177 event_params->Set(CreateV8String(isolate, "treeID"), 1180 event_params->Set(CreateV8String(isolate, "treeID"),
1178 v8::Integer::New(GetIsolate(), params.tree_id)); 1181 v8::Integer::New(GetIsolate(), params.tree_id));
1179 event_params->Set(CreateV8String(isolate, "targetID"), 1182 event_params->Set(CreateV8String(isolate, "targetID"),
1180 v8::Integer::New(GetIsolate(), params.id)); 1183 v8::Integer::New(GetIsolate(), params.id));
1181 event_params->Set(CreateV8String(isolate, "eventType"), 1184 event_params->Set(CreateV8String(isolate, "eventType"),
1182 CreateV8String(isolate, ToString(params.event_type))); 1185 CreateV8String(isolate, ToString(params.event_type)));
1183 event_params->Set(CreateV8String(isolate, "eventFrom"), 1186 event_params->Set(CreateV8String(isolate, "eventFrom"),
1184 CreateV8String(isolate, ToString(params.event_from))); 1187 CreateV8String(isolate, ToString(params.event_from)));
1185 event_params->Set(CreateV8String(isolate, "mouseX"), 1188 event_params->Set(CreateV8String(isolate, "mouseX"),
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
1412 v8::Local<v8::Array> args(v8::Array::New(GetIsolate(), 2U)); 1415 v8::Local<v8::Array> args(v8::Array::New(GetIsolate(), 2U));
1413 args->Set(0U, v8::Integer::New(GetIsolate(), tree_id)); 1416 args->Set(0U, v8::Integer::New(GetIsolate(), tree_id));
1414 v8::Local<v8::Array> nodes(v8::Array::New(GetIsolate(), ids.size())); 1417 v8::Local<v8::Array> nodes(v8::Array::New(GetIsolate(), ids.size()));
1415 args->Set(1U, nodes); 1418 args->Set(1U, nodes);
1416 for (size_t i = 0; i < ids.size(); ++i) 1419 for (size_t i = 0; i < ids.size(); ++i)
1417 nodes->Set(i, v8::Integer::New(GetIsolate(), ids[i])); 1420 nodes->Set(i, v8::Integer::New(GetIsolate(), ids[i]));
1418 context()->DispatchEvent("automationInternal.onNodesRemoved", args); 1421 context()->DispatchEvent("automationInternal.onNodesRemoved", args);
1419 } 1422 }
1420 1423
1421 } // namespace extensions 1424 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698