Chromium Code Reviews| Index: net/quic/quartc/quartc_at_exit.cc |
| diff --git a/net/quic/quartc/quartc_at_exit.cc b/net/quic/quartc/quartc_at_exit.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ebd898d51f1008e5e9851218ad562832ada0e85a |
| --- /dev/null |
| +++ b/net/quic/quartc/quartc_at_exit.cc |
| @@ -0,0 +1,44 @@ |
| +// Copyright (c) 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "net/quic/quartc/quartc_at_exit.h" |
| + |
| +namespace { |
| + |
| +// A test mode AtExitManager which is allowed be create more than one. |
| +// This should only be used for testing! AtExitManagers are kept on a global |
| +// stack, and it will be removed during destruction. This allows you to shadow |
| +// another AtExitManager. |
| +// Create a subclass as the test mode constructor of the AtExitManager is |
| +// protected. |
|
pthatcher1
2016/10/14 18:58:59
"as the" => "because the"
zhihuang1
2016/10/16 00:45:27
Done.
|
| +class AtExitManagerForTest : public base::AtExitManager { |
| + public: |
| + AtExitManagerForTest() : AtExitManager(true) {} |
| +}; |
| +} // namespace |
| + |
| +namespace net { |
| + |
| +QuartcAtExitManager::QuartcAtExitManager() {} |
| + |
| +QuartcAtExitManager::~QuartcAtExitManager() {} |
| + |
| +void QuartcAtExitManager::SetAtExitManager(bool test_mode) { |
| + if (at_exit_manager_) { |
|
pthatcher1
2016/10/14 18:58:59
If the QuartcAtExitManager itsn't usable until aft
zhihuang1
2016/10/16 00:45:27
One reason I'm doing this when working in WebRTC,
|
| + LOG(WARNING) << "The AtExitManager has already been created"; |
| + return; |
| + } |
| + if (test_mode) { |
| + // Only create ShadowingAtExitManager for unit tests. |
| + LOG(WARNING) << "Creating an AtExitManager for tests."; |
| + at_exit_manager_.reset(new AtExitManagerForTest); |
| + } else { |
| + at_exit_manager_.reset(new base::AtExitManager); |
| + } |
|
pthatcher1
2016/10/14 18:58:59
An alternative is to rename AtExitManagerForTest t
zhihuang1
2016/10/16 00:45:27
I think you mean we can have something like this:
|
| +} |
| + |
| +std::unique_ptr<QuartcAtExitManagerInterface> CreateQuartcAtExitManager() { |
| + return std::unique_ptr<QuartcAtExitManagerInterface>(new QuartcAtExitManager); |
|
pthatcher1
2016/10/14 18:58:59
What's the point of having a function that just ca
zhihuang1
2016/10/16 00:45:27
I thought this QuartcAtExitManager is something li
|
| +} |
| +} // namespace net |