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

Side by Side Diff: sync/internal_api/http_bridge_unittest.cc

Issue 73723006: Allow customization of HttpPostProviderFactory via ProfileSyncService (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 "base/message_loop/message_loop_proxy.h" 5 #include "base/message_loop/message_loop_proxy.h"
6 #include "base/synchronization/waitable_event.h" 6 #include "base/synchronization/waitable_event.h"
7 #include "base/threading/thread.h" 7 #include "base/threading/thread.h"
8 #include "net/test/spawned_test_server/spawned_test_server.h" 8 #include "net/test/spawned_test_server/spawned_test_server.h"
9 #include "net/url_request/test_url_fetcher_factory.h" 9 #include "net/url_request/test_url_fetcher_factory.h"
10 #include "net/url_request/url_fetcher_delegate.h" 10 #include "net/url_request/url_fetcher_delegate.h"
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 408
409 void HttpBridgeRunOnSyncThread( 409 void HttpBridgeRunOnSyncThread(
410 net::URLRequestContextGetter* baseline_context_getter, 410 net::URLRequestContextGetter* baseline_context_getter,
411 CancelationSignal* factory_cancelation_signal, 411 CancelationSignal* factory_cancelation_signal,
412 syncer::HttpPostProviderFactory** bridge_factory_out, 412 syncer::HttpPostProviderFactory** bridge_factory_out,
413 syncer::HttpPostProviderInterface** bridge_out, 413 syncer::HttpPostProviderInterface** bridge_out,
414 base::WaitableEvent* signal_when_created, 414 base::WaitableEvent* signal_when_created,
415 base::WaitableEvent* wait_for_shutdown) { 415 base::WaitableEvent* wait_for_shutdown) {
416 scoped_ptr<syncer::HttpBridgeFactory> bridge_factory( 416 scoped_ptr<syncer::HttpBridgeFactory> bridge_factory(
417 new syncer::HttpBridgeFactory(baseline_context_getter, 417 new syncer::HttpBridgeFactory(baseline_context_getter,
418 NetworkTimeUpdateCallback(), 418 NetworkTimeUpdateCallback()));
419 factory_cancelation_signal)); 419 bridge_factory->RegisterCancelationSignal(factory_cancelation_signal);
420 bridge_factory->Init("test"); 420 bridge_factory->Init("test");
421 *bridge_factory_out = bridge_factory.get(); 421 *bridge_factory_out = bridge_factory.get();
422 422
423 HttpPostProviderInterface* bridge = bridge_factory->Create(); 423 HttpPostProviderInterface* bridge = bridge_factory->Create();
424 *bridge_out = bridge; 424 *bridge_out = bridge;
425 425
426 signal_when_created->Signal(); 426 signal_when_created->Signal();
427 wait_for_shutdown->Wait(); 427 wait_for_shutdown->Wait();
428 428
429 bridge_factory->Destroy(bridge); 429 bridge_factory->Destroy(bridge);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 // simplicity, this test uses only one thread. 495 // simplicity, this test uses only one thread.
496 496
497 scoped_refptr<net::URLRequestContextGetter> baseline_context_getter( 497 scoped_refptr<net::URLRequestContextGetter> baseline_context_getter(
498 new net::TestURLRequestContextGetter(io_thread()->message_loop_proxy())); 498 new net::TestURLRequestContextGetter(io_thread()->message_loop_proxy()));
499 CancelationSignal release_request_context_signal; 499 CancelationSignal release_request_context_signal;
500 500
501 // UI Thread: Initialize the HttpBridgeFactory. The next step would be to 501 // UI Thread: Initialize the HttpBridgeFactory. The next step would be to
502 // post a task to SBH::Core to have it initialized. 502 // post a task to SBH::Core to have it initialized.
503 scoped_ptr<syncer::HttpBridgeFactory> factory(new HttpBridgeFactory( 503 scoped_ptr<syncer::HttpBridgeFactory> factory(new HttpBridgeFactory(
504 baseline_context_getter, 504 baseline_context_getter,
505 NetworkTimeUpdateCallback(), 505 NetworkTimeUpdateCallback()));
506 &release_request_context_signal)); 506 factory->RegisterCancelationSignal(&release_request_context_signal);
507 507
508 // UI Thread: A very early shutdown request arrives and executes on the UI 508 // UI Thread: A very early shutdown request arrives and executes on the UI
509 // thread before the posted sync thread task is run. 509 // thread before the posted sync thread task is run.
510 release_request_context_signal.Signal(); 510 release_request_context_signal.Signal();
511 511
512 // Sync thread: Finally run the posted task, only to find that our 512 // Sync thread: Finally run the posted task, only to find that our
513 // HttpBridgeFactory has been neutered. Should not crash. 513 // HttpBridgeFactory has been neutered. Should not crash.
514 factory->Init("TestUserAgent"); 514 factory->Init("TestUserAgent");
515 515
516 // At this point, attempting to use the factory would trigger a crash. Both 516 // At this point, attempting to use the factory would trigger a crash. Both
517 // this test and the real world code should make sure this never happens. 517 // this test and the real world code should make sure this never happens.
518 }; 518 };
519 519
520 } // namespace syncer 520 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698