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

Side by Side Diff: chrome/browser/automation/automation_provider_observers.cc

Issue 6623071: Fix AutomationProvider from logging false errors by replacing the persistent (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: little fix Created 9 years, 9 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/browser/automation/automation_provider_observers.h" 5 #include "chrome/browser/automation/automation_provider_observers.h"
6 6
7 #include <deque> 7 #include <deque>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 982 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 void DomOperationObserver::Observe( 993 void DomOperationObserver::Observe(
994 NotificationType type, const NotificationSource& source, 994 NotificationType type, const NotificationSource& source,
995 const NotificationDetails& details) { 995 const NotificationDetails& details) {
996 if (NotificationType::DOM_OPERATION_RESPONSE == type) { 996 if (NotificationType::DOM_OPERATION_RESPONSE == type) {
997 Details<DomOperationNotificationDetails> dom_op_details(details); 997 Details<DomOperationNotificationDetails> dom_op_details(details);
998 OnDomOperationCompleted(dom_op_details->json()); 998 OnDomOperationCompleted(dom_op_details->json());
999 } 999 }
1000 } 1000 }
1001 1001
1002 DomOperationMessageSender::DomOperationMessageSender( 1002 DomOperationMessageSender::DomOperationMessageSender(
1003 AutomationProvider* automation) 1003 AutomationProvider* automation,
1004 : automation_(automation->AsWeakPtr()) { 1004 IPC::Message* reply_message,
1005 bool use_json_interface)
1006 : automation_(automation->AsWeakPtr()),
1007 reply_message_(reply_message),
1008 use_json_interface_(use_json_interface) {
1005 } 1009 }
1006 1010
1007 DomOperationMessageSender::~DomOperationMessageSender() {} 1011 DomOperationMessageSender::~DomOperationMessageSender() {}
1008 1012
1009 void DomOperationMessageSender::OnDomOperationCompleted( 1013 void DomOperationMessageSender::OnDomOperationCompleted(
1010 const std::string& json) { 1014 const std::string& json) {
1011 if (!automation_) 1015 if (automation_) {
1012 return; 1016 if (use_json_interface_) {
1013 1017 DictionaryValue dict;
1014 IPC::Message* reply_message = automation_->reply_message_release(); 1018 dict.SetString("result", json);
1015 if (reply_message) { 1019 AutomationJSONReply(automation_, reply_message_.release())
1016 AutomationMsg_DomOperation::WriteReplyParams(reply_message, json); 1020 .SendSuccess(&dict);
1017 automation_->Send(reply_message); 1021 } else {
1018 } else { 1022 AutomationMsg_DomOperation::WriteReplyParams(reply_message_.get(), json);
1019 LOG(ERROR) << "DOM operation completed, but no reply message"; 1023 automation_->Send(reply_message_.release());
1024 }
1020 } 1025 }
1026 delete this;
1021 } 1027 }
1022 1028
1023 DocumentPrintedNotificationObserver::DocumentPrintedNotificationObserver( 1029 DocumentPrintedNotificationObserver::DocumentPrintedNotificationObserver(
1024 AutomationProvider* automation, IPC::Message* reply_message) 1030 AutomationProvider* automation, IPC::Message* reply_message)
1025 : automation_(automation->AsWeakPtr()), 1031 : automation_(automation->AsWeakPtr()),
1026 success_(false), 1032 success_(false),
1027 reply_message_(reply_message) { 1033 reply_message_(reply_message) {
1028 registrar_.Add(this, NotificationType::PRINT_JOB_EVENT, 1034 registrar_.Add(this, NotificationType::PRINT_JOB_EVENT,
1029 NotificationService::AllSources()); 1035 NotificationService::AllSources());
1030 } 1036 }
(...skipping 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after
2105 this, 2111 this,
2106 &WaitForProcessLauncherThreadToGoIdleObserver::RunOnUIThread)); 2112 &WaitForProcessLauncherThreadToGoIdleObserver::RunOnUIThread));
2107 } 2113 }
2108 2114
2109 void WaitForProcessLauncherThreadToGoIdleObserver::RunOnUIThread() { 2115 void WaitForProcessLauncherThreadToGoIdleObserver::RunOnUIThread() {
2110 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 2116 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
2111 if (automation_) 2117 if (automation_)
2112 automation_->Send(reply_message_.release()); 2118 automation_->Send(reply_message_.release());
2113 Release(); 2119 Release();
2114 } 2120 }
2115
2116 ExecuteJavascriptObserver::ExecuteJavascriptObserver(
2117 AutomationProvider* automation,
2118 IPC::Message* reply_message)
2119 : automation_(automation->AsWeakPtr()),
2120 reply_message_(reply_message) {
2121 }
2122
2123 ExecuteJavascriptObserver::~ExecuteJavascriptObserver() {
2124 }
2125
2126 void ExecuteJavascriptObserver::OnDomOperationCompleted(
2127 const std::string& json) {
2128 if (automation_) {
2129 DictionaryValue dict;
2130 dict.SetString("result", json);
2131 AutomationJSONReply(automation_, reply_message_.release())
2132 .SendSuccess(&dict);
2133 }
2134 delete this;
2135 }
OLDNEW
« no previous file with comments | « chrome/browser/automation/automation_provider_observers.h ('k') | chrome/browser/automation/testing_automation_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698