OLD | NEW |
1 // Copyright (c) 2010 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 "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
6 | 6 |
7 #include "base/stl_util-inl.h" | 7 #include "base/stl_util-inl.h" |
8 #include "base/threading/thread.h" | 8 #include "base/threading/thread.h" |
9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
11 #include "net/http/http_response_headers.h" | 11 #include "net/http/http_response_headers.h" |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 explicit IOThread(const char* name) | 467 explicit IOThread(const char* name) |
468 : base::Thread(name), old_factory_(NULL) { | 468 : base::Thread(name), old_factory_(NULL) { |
469 } | 469 } |
470 | 470 |
471 ~IOThread() { | 471 ~IOThread() { |
472 // We cannot rely on our base class to stop the thread since we want our | 472 // We cannot rely on our base class to stop the thread since we want our |
473 // CleanUp function to run. | 473 // CleanUp function to run. |
474 Stop(); | 474 Stop(); |
475 } | 475 } |
476 | 476 |
477 const scoped_refptr<URLRequestContext>& request_context() { | 477 const scoped_refptr<net::URLRequestContext>& request_context() { |
478 return request_context_; | 478 return request_context_; |
479 } | 479 } |
480 | 480 |
481 virtual void Init() { | 481 virtual void Init() { |
482 old_factory_ = net::URLRequest::RegisterProtocolFactory( | 482 old_factory_ = net::URLRequest::RegisterProtocolFactory( |
483 "http", MockHttpServer::JobFactory); | 483 "http", MockHttpServer::JobFactory); |
484 request_context_ = new TestURLRequestContext(); | 484 request_context_ = new TestURLRequestContext(); |
485 } | 485 } |
486 | 486 |
487 virtual void CleanUp() { | 487 virtual void CleanUp() { |
488 net::URLRequest::RegisterProtocolFactory("http", old_factory_); | 488 net::URLRequest::RegisterProtocolFactory("http", old_factory_); |
489 request_context_ = NULL; | 489 request_context_ = NULL; |
490 } | 490 } |
491 | 491 |
492 net::URLRequest::ProtocolFactory* old_factory_; | 492 net::URLRequest::ProtocolFactory* old_factory_; |
493 scoped_refptr<URLRequestContext> request_context_; | 493 scoped_refptr<net::URLRequestContext> request_context_; |
494 }; | 494 }; |
495 | 495 |
496 } // namespace | 496 } // namespace |
497 | 497 |
498 class AppCacheUpdateJobTest : public testing::Test, | 498 class AppCacheUpdateJobTest : public testing::Test, |
499 public AppCacheGroup::UpdateObserver { | 499 public AppCacheGroup::UpdateObserver { |
500 public: | 500 public: |
501 class MockAppCachePolicy : public AppCachePolicy { | 501 class MockAppCachePolicy : public AppCachePolicy { |
502 public: | 502 public: |
503 MockAppCachePolicy() | 503 MockAppCachePolicy() |
(...skipping 2954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3458 RunTestOnIOThread(&AppCacheUpdateJobTest::MultipleHeadersRefetchTest); | 3458 RunTestOnIOThread(&AppCacheUpdateJobTest::MultipleHeadersRefetchTest); |
3459 } | 3459 } |
3460 | 3460 |
3461 } // namespace appcache | 3461 } // namespace appcache |
3462 | 3462 |
3463 // AppCacheUpdateJobTest is expected to always live longer than the | 3463 // AppCacheUpdateJobTest is expected to always live longer than the |
3464 // runnable methods. This lets us call NewRunnableMethod on its instances. | 3464 // runnable methods. This lets us call NewRunnableMethod on its instances. |
3465 DISABLE_RUNNABLE_METHOD_REFCOUNT(appcache::AppCacheUpdateJobTest); | 3465 DISABLE_RUNNABLE_METHOD_REFCOUNT(appcache::AppCacheUpdateJobTest); |
3466 DISABLE_RUNNABLE_METHOD_REFCOUNT( | 3466 DISABLE_RUNNABLE_METHOD_REFCOUNT( |
3467 appcache::AppCacheUpdateJobTest::MockAppCachePolicy); | 3467 appcache::AppCacheUpdateJobTest::MockAppCachePolicy); |
OLD | NEW |