| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "mojo/fetcher/data_fetcher.h" | 5 #include "mojo/fetcher/data_fetcher.h" |
| 6 | 6 |
| 7 #include <utility> |
| 8 |
| 7 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 8 #include "base/bind.h" | 10 #include "base/bind.h" |
| 9 #include "base/logging.h" | 11 #include "base/logging.h" |
| 10 #include "base/macros.h" | 12 #include "base/macros.h" |
| 11 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
| 13 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
| 14 #include "mojo/public/cpp/system/data_pipe.h" | 16 #include "mojo/public/cpp/system/data_pipe.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 18 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 31 void WaitForCallback() { | 33 void WaitForCallback() { |
| 32 base::RunLoop run_loop; | 34 base::RunLoop run_loop; |
| 33 base::AutoReset<base::RunLoop*> auto_reset(&run_loop_, &run_loop); | 35 base::AutoReset<base::RunLoop*> auto_reset(&run_loop_, &run_loop); |
| 34 run_loop.Run(); | 36 run_loop.Run(); |
| 35 } | 37 } |
| 36 | 38 |
| 37 shell::Fetcher* fetcher() const { return fetcher_.get(); } | 39 shell::Fetcher* fetcher() const { return fetcher_.get(); } |
| 38 | 40 |
| 39 private: | 41 private: |
| 40 void CallbackHandler(scoped_ptr<shell::Fetcher> fetcher) { | 42 void CallbackHandler(scoped_ptr<shell::Fetcher> fetcher) { |
| 41 fetcher_ = fetcher.Pass(); | 43 fetcher_ = std::move(fetcher); |
| 42 if (run_loop_) | 44 if (run_loop_) |
| 43 run_loop_->Quit(); | 45 run_loop_->Quit(); |
| 44 } | 46 } |
| 45 | 47 |
| 46 // If it is not null, it points to a stack-allocated base::RunLoop instance in | 48 // If it is not null, it points to a stack-allocated base::RunLoop instance in |
| 47 // WaitForCallback(). | 49 // WaitForCallback(). |
| 48 base::RunLoop* run_loop_; | 50 base::RunLoop* run_loop_; |
| 49 scoped_ptr<shell::Fetcher> fetcher_; | 51 scoped_ptr<shell::Fetcher> fetcher_; |
| 50 DISALLOW_COPY_AND_ASSIGN(FetchCallbackHelper); | 52 DISALLOW_COPY_AND_ASSIGN(FetchCallbackHelper); |
| 51 }; | 53 }; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 } | 102 } |
| 101 | 103 |
| 102 TEST_F(DataFetcherTest, BasicFailure) { | 104 TEST_F(DataFetcherTest, BasicFailure) { |
| 103 TestFetchURL("about:blank", 400, std::string(), std::string()); | 105 TestFetchURL("about:blank", 400, std::string(), std::string()); |
| 104 TestFetchURL("data:;base64,aGVs_-_-", 400, std::string(), std::string()); | 106 TestFetchURL("data:;base64,aGVs_-_-", 400, std::string(), std::string()); |
| 105 } | 107 } |
| 106 | 108 |
| 107 } // namespace | 109 } // namespace |
| 108 } // namespace fetcher | 110 } // namespace fetcher |
| 109 } // namespace mojo | 111 } // namespace mojo |
| OLD | NEW |