| OLD | NEW |
| 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 "content/browser/media/media_internals.h" | 5 #include "content/browser/media/media_internals.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 audio_log_(media_internals_->CreateAudioLog(test_component_)) { | 38 audio_log_(media_internals_->CreateAudioLog(test_component_)) { |
| 39 media_internals_->AddUpdateCallback(update_cb_); | 39 media_internals_->AddUpdateCallback(update_cb_); |
| 40 } | 40 } |
| 41 | 41 |
| 42 virtual ~MediaInternalsTest() { | 42 virtual ~MediaInternalsTest() { |
| 43 media_internals_->RemoveUpdateCallback(update_cb_); | 43 media_internals_->RemoveUpdateCallback(update_cb_); |
| 44 } | 44 } |
| 45 | 45 |
| 46 protected: | 46 protected: |
| 47 // Extracts and deserializes the JSON update data; merges into |update_data_|. | 47 // Extracts and deserializes the JSON update data; merges into |update_data_|. |
| 48 void UpdateCallbackImpl(const string16& update) { | 48 void UpdateCallbackImpl(const base::string16& update) { |
| 49 // Each update string looks like "<JavaScript Function Name>({<JSON>});", to | 49 // Each update string looks like "<JavaScript Function Name>({<JSON>});", to |
| 50 // use the JSON reader we need to strip out the JavaScript code. | 50 // use the JSON reader we need to strip out the JavaScript code. |
| 51 std::string utf8_update = base::UTF16ToUTF8(update); | 51 std::string utf8_update = base::UTF16ToUTF8(update); |
| 52 const std::string::size_type first_brace = utf8_update.find('{'); | 52 const std::string::size_type first_brace = utf8_update.find('{'); |
| 53 const std::string::size_type last_brace = utf8_update.rfind('}'); | 53 const std::string::size_type last_brace = utf8_update.rfind('}'); |
| 54 scoped_ptr<base::Value> output_value(base::JSONReader::Read( | 54 scoped_ptr<base::Value> output_value(base::JSONReader::Read( |
| 55 utf8_update.substr(first_brace, last_brace - first_brace + 1))); | 55 utf8_update.substr(first_brace, last_brace - first_brace + 1))); |
| 56 CHECK(output_value); | 56 CHECK(output_value); |
| 57 | 57 |
| 58 base::DictionaryValue* output_dict = NULL; | 58 base::DictionaryValue* output_dict = NULL; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 ExpectStatus("closed"); | 137 ExpectStatus("closed"); |
| 138 } | 138 } |
| 139 | 139 |
| 140 INSTANTIATE_TEST_CASE_P( | 140 INSTANTIATE_TEST_CASE_P( |
| 141 MediaInternalsTest, MediaInternalsTest, testing::Values( | 141 MediaInternalsTest, MediaInternalsTest, testing::Values( |
| 142 media::AudioLogFactory::AUDIO_INPUT_CONTROLLER, | 142 media::AudioLogFactory::AUDIO_INPUT_CONTROLLER, |
| 143 media::AudioLogFactory::AUDIO_OUTPUT_CONTROLLER, | 143 media::AudioLogFactory::AUDIO_OUTPUT_CONTROLLER, |
| 144 media::AudioLogFactory::AUDIO_OUTPUT_STREAM)); | 144 media::AudioLogFactory::AUDIO_OUTPUT_STREAM)); |
| 145 | 145 |
| 146 } // namespace content | 146 } // namespace content |
| OLD | NEW |