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

Side by Side Diff: chrome/service/cloud_print/cloud_print_proxy_backend.cc

Issue 8491048: Fixed crash in the proxy. Reference has been passed between threads, (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 1 month 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
« no previous file with comments | « chrome/service/cloud_print/cloud_print_proxy_backend.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/service/cloud_print/cloud_print_proxy_backend.h" 5 #include "chrome/service/cloud_print/cloud_print_proxy_backend.h"
6 6
7 #include <map> 7 #include <map>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 75
76 // CloudPrintAuth::Client implementation. 76 // CloudPrintAuth::Client implementation.
77 virtual void OnAuthenticationComplete( 77 virtual void OnAuthenticationComplete(
78 const std::string& access_token, 78 const std::string& access_token,
79 const std::string& robot_oauth_refresh_token, 79 const std::string& robot_oauth_refresh_token,
80 const std::string& robot_email, 80 const std::string& robot_email,
81 const std::string& user_email); 81 const std::string& user_email);
82 virtual void OnInvalidCredentials(); 82 virtual void OnInvalidCredentials();
83 83
84 // CloudPrintConnector::Client implementation. 84 // CloudPrintConnector::Client implementation.
85 virtual void OnPrintersAvailable(const printing::PrinterList& printers);
86 virtual void OnAuthFailed(); 85 virtual void OnAuthFailed();
87 86
88 // notifier::TalkMediator::Delegate implementation. 87 // notifier::TalkMediator::Delegate implementation.
89 virtual void OnNotificationStateChange( 88 virtual void OnNotificationStateChange(
90 bool notifications_enabled); 89 bool notifications_enabled);
91 virtual void OnIncomingNotification( 90 virtual void OnIncomingNotification(
92 const notifier::Notification& notification); 91 const notifier::Notification& notification);
93 virtual void OnOutgoingNotification(); 92 virtual void OnOutgoingNotification();
94 93
95 private: 94 private:
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 } 231 }
233 232
234 void CloudPrintProxyBackend::Shutdown() { 233 void CloudPrintProxyBackend::Shutdown() {
235 core_thread_.message_loop()->PostTask(FROM_HERE, 234 core_thread_.message_loop()->PostTask(FROM_HERE,
236 NewRunnableMethod(core_.get(), 235 NewRunnableMethod(core_.get(),
237 &CloudPrintProxyBackend::Core::DoShutdown)); 236 &CloudPrintProxyBackend::Core::DoShutdown));
238 core_thread_.Stop(); 237 core_thread_.Stop();
239 core_ = NULL; // Releases reference to core_. 238 core_ = NULL; // Releases reference to core_.
240 } 239 }
241 240
242 void CloudPrintProxyBackend::RegisterPrinters(
243 const printing::PrinterList& printer_list) {
244 core_thread_.message_loop()->PostTask(FROM_HERE,
245 NewRunnableMethod(
246 core_.get(),
247 &CloudPrintProxyBackend::Core::DoRegisterSelectedPrinters,
248 printer_list));
249 }
250
251 CloudPrintProxyBackend::Core::Core( 241 CloudPrintProxyBackend::Core::Core(
252 CloudPrintProxyBackend* backend, 242 CloudPrintProxyBackend* backend,
253 const std::string& proxy_id, 243 const std::string& proxy_id,
254 const GURL& cloud_print_server_url, 244 const GURL& cloud_print_server_url,
255 const DictionaryValue* print_system_settings, 245 const DictionaryValue* print_system_settings,
256 const gaia::OAuthClientInfo& oauth_client_info, 246 const gaia::OAuthClientInfo& oauth_client_info,
257 bool enable_job_poll) 247 bool enable_job_poll)
258 : backend_(backend), 248 : backend_(backend),
259 cloud_print_server_url_(cloud_print_server_url), 249 cloud_print_server_url_(cloud_print_server_url),
260 proxy_id_(proxy_id), 250 proxy_id_(proxy_id),
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 } 334 }
345 } 335 }
346 336
347 void CloudPrintProxyBackend::Core::OnInvalidCredentials() { 337 void CloudPrintProxyBackend::Core::OnInvalidCredentials() {
348 DCHECK(MessageLoop::current() == backend_->core_thread_.message_loop()); 338 DCHECK(MessageLoop::current() == backend_->core_thread_.message_loop());
349 VLOG(1) << "CP_CONNECTOR: Auth Error"; 339 VLOG(1) << "CP_CONNECTOR: Auth Error";
350 backend_->frontend_loop_->PostTask(FROM_HERE, NewRunnableMethod(this, 340 backend_->frontend_loop_->PostTask(FROM_HERE, NewRunnableMethod(this,
351 &Core::NotifyAuthenticationFailed)); 341 &Core::NotifyAuthenticationFailed));
352 } 342 }
353 343
354 void CloudPrintProxyBackend::Core::OnPrintersAvailable(
355 const printing::PrinterList& printers) {
356 // Let the frontend know that we have a list of printers available.
357 backend_->frontend_loop_->PostTask(FROM_HERE, NewRunnableMethod(this,
358 &Core::NotifyPrinterListAvailable, printers));
359 }
360
361 void CloudPrintProxyBackend::Core::OnAuthFailed() { 344 void CloudPrintProxyBackend::Core::OnAuthFailed() {
362 VLOG(1) << "CP_CONNECTOR: Authentication failed in connector."; 345 VLOG(1) << "CP_CONNECTOR: Authentication failed in connector.";
363 // Let's stop connecter and refresh token. We'll restart connecter once 346 // Let's stop connecter and refresh token. We'll restart connecter once
364 // new token available. 347 // new token available.
365 if (connector_->IsRunning()) 348 if (connector_->IsRunning())
366 connector_->Stop(); 349 connector_->Stop();
367 350
368 // Refresh Auth token. 351 // Refresh Auth token.
369 auth_->RefreshAccessToken(); 352 auth_->RefreshAccessToken();
370 } 353 }
(...skipping 28 matching lines...) Expand all
399 382
400 // Important to delete the TalkMediator on this thread. 383 // Important to delete the TalkMediator on this thread.
401 if (talk_mediator_.get()) 384 if (talk_mediator_.get())
402 talk_mediator_->Logout(); 385 talk_mediator_->Logout();
403 talk_mediator_.reset(); 386 talk_mediator_.reset();
404 notifications_enabled_ = false; 387 notifications_enabled_ = false;
405 notifications_enabled_since_ = base::TimeTicks(); 388 notifications_enabled_since_ = base::TimeTicks();
406 token_store_.reset(); 389 token_store_.reset();
407 } 390 }
408 391
409 void CloudPrintProxyBackend::Core::DoRegisterSelectedPrinters(
410 const printing::PrinterList& printer_list) {
411 DCHECK(MessageLoop::current() == backend_->core_thread_.message_loop());
412 connector_->RegisterPrinters(printer_list);
413 }
414
415 void CloudPrintProxyBackend::Core::HandlePrinterNotification( 392 void CloudPrintProxyBackend::Core::HandlePrinterNotification(
416 const std::string& printer_id) { 393 const std::string& printer_id) {
417 DCHECK(MessageLoop::current() == backend_->core_thread_.message_loop()); 394 DCHECK(MessageLoop::current() == backend_->core_thread_.message_loop());
418 VLOG(1) << "CP_CONNECTOR: Handle printer notification, id: " << printer_id; 395 VLOG(1) << "CP_CONNECTOR: Handle printer notification, id: " << printer_id;
419 connector_->CheckForJobs(kJobFetchReasonNotified, printer_id); 396 connector_->CheckForJobs(kJobFetchReasonNotified, printer_id);
420 } 397 }
421 398
422 void CloudPrintProxyBackend::Core::PollForJobs() { 399 void CloudPrintProxyBackend::Core::PollForJobs() {
423 VLOG(1) << "CP_CONNECTOR: Polling for jobs."; 400 VLOG(1) << "CP_CONNECTOR: Polling for jobs.";
424 DCHECK(MessageLoop::current() == backend_->core_thread_.message_loop()); 401 DCHECK(MessageLoop::current() == backend_->core_thread_.message_loop());
(...skipping 19 matching lines...) Expand all
444 } 421 }
445 } 422 }
446 423
447 CloudPrintTokenStore* CloudPrintProxyBackend::Core::GetTokenStore() { 424 CloudPrintTokenStore* CloudPrintProxyBackend::Core::GetTokenStore() {
448 DCHECK(MessageLoop::current() == backend_->core_thread_.message_loop()); 425 DCHECK(MessageLoop::current() == backend_->core_thread_.message_loop());
449 if (!token_store_.get()) 426 if (!token_store_.get())
450 token_store_.reset(new CloudPrintTokenStore); 427 token_store_.reset(new CloudPrintTokenStore);
451 return token_store_.get(); 428 return token_store_.get();
452 } 429 }
453 430
454 void CloudPrintProxyBackend::Core::NotifyPrinterListAvailable(
455 const printing::PrinterList& printer_list) {
456 DCHECK(MessageLoop::current() == backend_->frontend_loop_);
457 backend_->frontend_->OnPrinterListAvailable(printer_list);
458 }
459
460 void CloudPrintProxyBackend::Core::NotifyAuthenticated( 431 void CloudPrintProxyBackend::Core::NotifyAuthenticated(
461 const std::string& robot_oauth_refresh_token, 432 const std::string& robot_oauth_refresh_token,
462 const std::string& robot_email, 433 const std::string& robot_email,
463 const std::string& user_email) { 434 const std::string& user_email) {
464 DCHECK(MessageLoop::current() == backend_->frontend_loop_); 435 DCHECK(MessageLoop::current() == backend_->frontend_loop_);
465 backend_->frontend_->OnAuthenticated(robot_oauth_refresh_token, 436 backend_->frontend_->OnAuthenticated(robot_oauth_refresh_token,
466 robot_email, 437 robot_email,
467 user_email); 438 user_email);
468 } 439 }
469 440
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 void CloudPrintProxyBackend::Core::OnIncomingNotification( 476 void CloudPrintProxyBackend::Core::OnIncomingNotification(
506 const notifier::Notification& notification) { 477 const notifier::Notification& notification) {
507 DCHECK(MessageLoop::current() == backend_->core_thread_.message_loop()); 478 DCHECK(MessageLoop::current() == backend_->core_thread_.message_loop());
508 VLOG(1) << "CP_CONNECTOR: Incoming notification."; 479 VLOG(1) << "CP_CONNECTOR: Incoming notification.";
509 if (0 == base::strcasecmp(kCloudPrintPushNotificationsSource, 480 if (0 == base::strcasecmp(kCloudPrintPushNotificationsSource,
510 notification.channel.c_str())) 481 notification.channel.c_str()))
511 HandlePrinterNotification(notification.data); 482 HandlePrinterNotification(notification.data);
512 } 483 }
513 484
514 void CloudPrintProxyBackend::Core::OnOutgoingNotification() {} 485 void CloudPrintProxyBackend::Core::OnOutgoingNotification() {}
OLDNEW
« no previous file with comments | « chrome/service/cloud_print/cloud_print_proxy_backend.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698