Commit d2547353 authored by gene@chromium.org's avatar gene@chromium.org

Fixed crash in the proxy. Reference has been passed between threads,

while object has been created on the stack of the first thread.
Removed backend-frontend communication as it is not needed.

BUG=103769
TEST=Verify GCP connector is running fine.
Review URL: http://codereview.chromium.org/8491048

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@109665 0039d316-1c4b-4281-b951-d872f2087c98
parent 578c1c45
...@@ -198,9 +198,10 @@ CloudPrintConnector::HandlePrinterListResponse( ...@@ -198,9 +198,10 @@ CloudPrintConnector::HandlePrinterListResponse(
request_ = NULL; request_ = NULL;
if (!local_printers.empty()) { if (!local_printers.empty()) {
// Notify client that we have a list of printers available. // In the future we might want to notify frontend about available printers
// Client will call us back to finish registration // and let user choose which printers to register.
client_->OnPrintersAvailable(local_printers); // Here is a good place to notify client about available printers.
RegisterPrinters(local_printers);
} }
ContinuePendingTaskProcessing(); // Continue processing background tasks. ContinuePendingTaskProcessing(); // Continue processing background tasks.
return CloudPrintURLFetcher::STOP_PROCESSING; return CloudPrintURLFetcher::STOP_PROCESSING;
......
...@@ -30,7 +30,6 @@ class CloudPrintConnector ...@@ -30,7 +30,6 @@ class CloudPrintConnector
public: public:
class Client { class Client {
public: public:
virtual void OnPrintersAvailable(const printing::PrinterList& printers) = 0;
virtual void OnAuthFailed() = 0; virtual void OnAuthFailed() = 0;
protected: protected:
virtual ~Client() {} virtual ~Client() {}
......
...@@ -188,15 +188,6 @@ void CloudPrintProxy::GetProxyInfo(cloud_print::CloudPrintProxyInfo* info) { ...@@ -188,15 +188,6 @@ void CloudPrintProxy::GetProxyInfo(cloud_print::CloudPrintProxyInfo* info) {
service_prefs_->GetString(prefs::kCloudPrintProxyId, &info->proxy_id); service_prefs_->GetString(prefs::kCloudPrintProxyId, &info->proxy_id);
} }
// Notification methods from the backend. Called on UI thread.
void CloudPrintProxy::OnPrinterListAvailable(
const printing::PrinterList& printer_list) {
DCHECK(CalledOnValidThread());
// We could potentially show UI here allowing the user to select which
// printers to register. For now, we just register all.
backend_->RegisterPrinters(printer_list);
}
void CloudPrintProxy::OnAuthenticated( void CloudPrintProxy::OnAuthenticated(
const std::string& robot_oauth_refresh_token, const std::string& robot_oauth_refresh_token,
const std::string& robot_email, const std::string& robot_email,
......
...@@ -52,8 +52,6 @@ class CloudPrintProxy : public CloudPrintProxyFrontend, ...@@ -52,8 +52,6 @@ class CloudPrintProxy : public CloudPrintProxyFrontend,
} }
// CloudPrintProxyFrontend implementation. Called on UI thread. // CloudPrintProxyFrontend implementation. Called on UI thread.
virtual void OnPrinterListAvailable(
const printing::PrinterList& printer_list);
virtual void OnAuthenticated(const std::string& robot_oauth_refresh_token, virtual void OnAuthenticated(const std::string& robot_oauth_refresh_token,
const std::string& robot_email, const std::string& robot_email,
const std::string& user_email); const std::string& user_email);
......
...@@ -82,7 +82,6 @@ class CloudPrintProxyBackend::Core ...@@ -82,7 +82,6 @@ class CloudPrintProxyBackend::Core
virtual void OnInvalidCredentials(); virtual void OnInvalidCredentials();
// CloudPrintConnector::Client implementation. // CloudPrintConnector::Client implementation.
virtual void OnPrintersAvailable(const printing::PrinterList& printers);
virtual void OnAuthFailed(); virtual void OnAuthFailed();
// notifier::TalkMediator::Delegate implementation. // notifier::TalkMediator::Delegate implementation.
...@@ -239,15 +238,6 @@ void CloudPrintProxyBackend::Shutdown() { ...@@ -239,15 +238,6 @@ void CloudPrintProxyBackend::Shutdown() {
core_ = NULL; // Releases reference to core_. core_ = NULL; // Releases reference to core_.
} }
void CloudPrintProxyBackend::RegisterPrinters(
const printing::PrinterList& printer_list) {
core_thread_.message_loop()->PostTask(FROM_HERE,
NewRunnableMethod(
core_.get(),
&CloudPrintProxyBackend::Core::DoRegisterSelectedPrinters,
printer_list));
}
CloudPrintProxyBackend::Core::Core( CloudPrintProxyBackend::Core::Core(
CloudPrintProxyBackend* backend, CloudPrintProxyBackend* backend,
const std::string& proxy_id, const std::string& proxy_id,
...@@ -351,13 +341,6 @@ void CloudPrintProxyBackend::Core::OnInvalidCredentials() { ...@@ -351,13 +341,6 @@ void CloudPrintProxyBackend::Core::OnInvalidCredentials() {
&Core::NotifyAuthenticationFailed)); &Core::NotifyAuthenticationFailed));
} }
void CloudPrintProxyBackend::Core::OnPrintersAvailable(
const printing::PrinterList& printers) {
// Let the frontend know that we have a list of printers available.
backend_->frontend_loop_->PostTask(FROM_HERE, NewRunnableMethod(this,
&Core::NotifyPrinterListAvailable, printers));
}
void CloudPrintProxyBackend::Core::OnAuthFailed() { void CloudPrintProxyBackend::Core::OnAuthFailed() {
VLOG(1) << "CP_CONNECTOR: Authentication failed in connector."; VLOG(1) << "CP_CONNECTOR: Authentication failed in connector.";
// Let's stop connecter and refresh token. We'll restart connecter once // Let's stop connecter and refresh token. We'll restart connecter once
...@@ -406,12 +389,6 @@ void CloudPrintProxyBackend::Core::DoShutdown() { ...@@ -406,12 +389,6 @@ void CloudPrintProxyBackend::Core::DoShutdown() {
token_store_.reset(); token_store_.reset();
} }
void CloudPrintProxyBackend::Core::DoRegisterSelectedPrinters(
const printing::PrinterList& printer_list) {
DCHECK(MessageLoop::current() == backend_->core_thread_.message_loop());
connector_->RegisterPrinters(printer_list);
}
void CloudPrintProxyBackend::Core::HandlePrinterNotification( void CloudPrintProxyBackend::Core::HandlePrinterNotification(
const std::string& printer_id) { const std::string& printer_id) {
DCHECK(MessageLoop::current() == backend_->core_thread_.message_loop()); DCHECK(MessageLoop::current() == backend_->core_thread_.message_loop());
...@@ -451,12 +428,6 @@ CloudPrintTokenStore* CloudPrintProxyBackend::Core::GetTokenStore() { ...@@ -451,12 +428,6 @@ CloudPrintTokenStore* CloudPrintProxyBackend::Core::GetTokenStore() {
return token_store_.get(); return token_store_.get();
} }
void CloudPrintProxyBackend::Core::NotifyPrinterListAvailable(
const printing::PrinterList& printer_list) {
DCHECK(MessageLoop::current() == backend_->frontend_loop_);
backend_->frontend_->OnPrinterListAvailable(printer_list);
}
void CloudPrintProxyBackend::Core::NotifyAuthenticated( void CloudPrintProxyBackend::Core::NotifyAuthenticated(
const std::string& robot_oauth_refresh_token, const std::string& robot_oauth_refresh_token,
const std::string& robot_email, const std::string& robot_email,
......
...@@ -31,9 +31,6 @@ class CloudPrintProxyFrontend { ...@@ -31,9 +31,6 @@ class CloudPrintProxyFrontend {
public: public:
CloudPrintProxyFrontend() {} CloudPrintProxyFrontend() {}
// There is a list of printers available that can be registered.
virtual void OnPrinterListAvailable(
const printing::PrinterList& printer_list) = 0;
// We successfully authenticated with the cloud print server. This callback // We successfully authenticated with the cloud print server. This callback
// allows the frontend to persist the tokens. // allows the frontend to persist the tokens.
virtual void OnAuthenticated(const std::string& robot_oauth_refresh_token, virtual void OnAuthenticated(const std::string& robot_oauth_refresh_token,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment