diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-20 23:46:41 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-20 23:46:41 +0000 |
commit | 6de9070e8a48d7faf1d723c5fd40ed29222c7125 (patch) | |
tree | a129ec5f371d9cd072053313c56b96b051f9706c | |
parent | 061239ca0a4d26d8d88ca2db94cb1a330dae4928 (diff) | |
download | chromium_src-6de9070e8a48d7faf1d723c5fd40ed29222c7125.zip chromium_src-6de9070e8a48d7faf1d723c5fd40ed29222c7125.tar.gz chromium_src-6de9070e8a48d7faf1d723c5fd40ed29222c7125.tar.bz2 |
Revert 127797 - Add NetworkListObserver utility class.
BUG=114808
Review URL: http://codereview.chromium.org/9696051
TBR=sergeyu@chromium.org
Review URL: https://chromiumcodereview.appspot.com/9801004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@127837 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/test/ui/ppapi_uitest.cc | 2 | ||||
-rw-r--r-- | ppapi/cpp/private/network_list_private.cc | 17 | ||||
-rw-r--r-- | ppapi/cpp/private/network_list_private.h | 15 | ||||
-rw-r--r-- | ppapi/ppapi_sources.gypi | 2 | ||||
-rw-r--r-- | ppapi/tests/test_network_monitor_private.cc | 52 | ||||
-rw-r--r-- | ppapi/tests/test_network_monitor_private.h | 8 | ||||
-rw-r--r-- | ppapi/utility/private/network_list_observer_private.cc | 34 | ||||
-rw-r--r-- | ppapi/utility/private/network_list_observer_private.h | 42 |
8 files changed, 24 insertions, 148 deletions
diff --git a/chrome/test/ui/ppapi_uitest.cc b/chrome/test/ui/ppapi_uitest.cc index cefd22a..8448aa3 100644 --- a/chrome/test/ui/ppapi_uitest.cc +++ b/chrome/test/ui/ppapi_uitest.cc @@ -805,8 +805,6 @@ TEST_PPAPI_IN_PROCESS(NetworkMonitorPrivate_2Monitors) TEST_PPAPI_OUT_OF_PROCESS(NetworkMonitorPrivate_2Monitors) TEST_PPAPI_IN_PROCESS(NetworkMonitorPrivate_DeleteInCallback) TEST_PPAPI_OUT_OF_PROCESS(NetworkMonitorPrivate_DeleteInCallback) -TEST_PPAPI_IN_PROCESS(NetworkMonitorPrivate_ListObserver) -TEST_PPAPI_OUT_OF_PROCESS(NetworkMonitorPrivate_ListObserver) // PPB_TCPSocket_Private currently isn't supported in-process. IN_PROC_BROWSER_TEST_F(OutOfProcessPPAPITest, TCPSocketPrivate) { diff --git a/ppapi/cpp/private/network_list_private.cc b/ppapi/cpp/private/network_list_private.cc index 84990a2..d08410e 100644 --- a/ppapi/cpp/private/network_list_private.cc +++ b/ppapi/cpp/private/network_list_private.cc @@ -17,9 +17,6 @@ template <> const char* interface_name<PPB_NetworkList_Private>() { } // namespace -NetworkListPrivate::NetworkListPrivate() { -} - NetworkListPrivate::NetworkListPrivate(PP_Resource resource) : Resource(resource) { } @@ -29,13 +26,13 @@ bool NetworkListPrivate::IsAvailable() { return has_interface<PPB_NetworkList_Private>(); } -uint32_t NetworkListPrivate::GetCount() const { +uint32_t NetworkListPrivate::GetCount() { if (!has_interface<PPB_NetworkList_Private>()) return 0; return get_interface<PPB_NetworkList_Private>()->GetCount(pp_resource()); } -std::string NetworkListPrivate::GetName(uint32_t index) const { +std::string NetworkListPrivate::GetName(uint32_t index) { if (!has_interface<PPB_NetworkList_Private>()) return std::string(); Var result(PASS_REF, @@ -44,14 +41,14 @@ std::string NetworkListPrivate::GetName(uint32_t index) const { return result.is_string() ? result.AsString() : std::string(); } -PP_NetworkListType_Private NetworkListPrivate::GetType(uint32_t index) const { +PP_NetworkListType_Private NetworkListPrivate::GetType(uint32_t index) { if (!has_interface<PPB_NetworkList_Private>()) return PP_NETWORKLIST_ETHERNET; return get_interface<PPB_NetworkList_Private>()->GetType( pp_resource(), index); } -PP_NetworkListState_Private NetworkListPrivate::GetState(uint32_t index) const { +PP_NetworkListState_Private NetworkListPrivate::GetState(uint32_t index) { if (!has_interface<PPB_NetworkList_Private>()) return PP_NETWORKLIST_DOWN; return get_interface<PPB_NetworkList_Private>()->GetState( @@ -60,7 +57,7 @@ PP_NetworkListState_Private NetworkListPrivate::GetState(uint32_t index) const { void NetworkListPrivate::GetIpAddresses( uint32_t index, - std::vector<PP_NetAddress_Private>* addresses) const { + std::vector<PP_NetAddress_Private>* addresses) { if (!has_interface<PPB_NetworkList_Private>()) return; @@ -91,7 +88,7 @@ void NetworkListPrivate::GetIpAddresses( } } -std::string NetworkListPrivate::GetDisplayName(uint32_t index) const { +std::string NetworkListPrivate::GetDisplayName(uint32_t index) { if (!has_interface<PPB_NetworkList_Private>()) return std::string(); Var result(PASS_REF, @@ -100,7 +97,7 @@ std::string NetworkListPrivate::GetDisplayName(uint32_t index) const { return result.is_string() ? result.AsString() : std::string(); } -uint32_t NetworkListPrivate::GetMTU(uint32_t index) const { +uint32_t NetworkListPrivate::GetMTU(uint32_t index) { if (!has_interface<PPB_NetworkList_Private>()) return 0; return get_interface<PPB_NetworkList_Private>()->GetMTU( diff --git a/ppapi/cpp/private/network_list_private.h b/ppapi/cpp/private/network_list_private.h index d614362..223941d1 100644 --- a/ppapi/cpp/private/network_list_private.h +++ b/ppapi/cpp/private/network_list_private.h @@ -15,7 +15,6 @@ namespace pp { class NetworkListPrivate : public Resource { public: - NetworkListPrivate(); explicit NetworkListPrivate(PP_Resource resource); /// Returns true if the required interface is available. @@ -23,33 +22,33 @@ class NetworkListPrivate : public Resource { /// @return Returns the number of available network interfaces or 0 /// if the list has never been updated. - uint32_t GetCount() const; + uint32_t GetCount(); /// @return Returns the name for the network interface with the /// specified <code>index</code>. - std::string GetName(uint32_t index) const; + std::string GetName(uint32_t index); /// @return Returns the type of the network interface with the /// specified <code>index</code>. - PP_NetworkListType_Private GetType(uint32_t index) const; + PP_NetworkListType_Private GetType(uint32_t index); /// @return Returns the current state of the network interface with /// the specified <code>index</code>. - PP_NetworkListState_Private GetState(uint32_t index) const; + PP_NetworkListState_Private GetState(uint32_t index); /// Gets the list of IP addresses for the network interface with the /// specified <code>index</code> and stores them in /// <code>addresses</code>. void GetIpAddresses(uint32_t index, - std::vector<PP_NetAddress_Private>* addresses) const; + std::vector<PP_NetAddress_Private>* addresses); /// @return Returns the display name for the network interface with /// the specified <code>index</code>. - std::string GetDisplayName(uint32_t index) const; + std::string GetDisplayName(uint32_t index); /// @return Returns the MTU for the network interface with the /// specified <code>index</code>. - uint32_t GetMTU(uint32_t index) const; + uint32_t GetMTU(uint32_t index); }; } // namespace pp diff --git a/ppapi/ppapi_sources.gypi b/ppapi/ppapi_sources.gypi index e724196..f3c7b5f 100644 --- a/ppapi/ppapi_sources.gypi +++ b/ppapi/ppapi_sources.gypi @@ -288,8 +288,6 @@ 'utility/graphics/paint_aggregator.h', 'utility/graphics/paint_manager.cc', 'utility/graphics/paint_manager.h', - 'utility/private/network_list_observer_private.cc', - 'utility/private/network_list_observer_private.h', 'utility/threading/simple_thread.cc', 'utility/threading/simple_thread.h', 'utility/websocket/websocket_api.cc', diff --git a/ppapi/tests/test_network_monitor_private.cc b/ppapi/tests/test_network_monitor_private.cc index 6583cc4..fa87ec1 100644 --- a/ppapi/tests/test_network_monitor_private.cc +++ b/ppapi/tests/test_network_monitor_private.cc @@ -6,14 +6,12 @@ #include <string.h> -#include "ppapi/cpp/instance_handle.h" -#include "ppapi/cpp/module.h" #include "ppapi/cpp/private/net_address_private.h" #include "ppapi/cpp/private/network_list_private.h" #include "ppapi/cpp/private/network_monitor_private.h" #include "ppapi/tests/testing_instance.h" #include "ppapi/tests/test_utils.h" -#include "ppapi/utility/private/network_list_observer_private.h" +#include "ppapi/cpp/module.h" REGISTER_TEST_CASE(NetworkMonitorPrivate); @@ -54,22 +52,6 @@ void TestCallback(void* user_data, PP_Resource network_list) { static_cast<pp::CompletionCallback>(data->completion_callback).Run(PP_OK); } - -class TestNetworkListObserver : public pp::NetworkListObserverPrivate { - public: - explicit TestNetworkListObserver(const pp::InstanceHandle& instance) - : pp::NetworkListObserverPrivate(instance), - completion_callback(instance.pp_instance()) { - } - virtual void OnNetworkListChanged(const pp::NetworkListPrivate& list) { - current_list = list; - static_cast<pp::CompletionCallback>(completion_callback).Run(PP_OK); - } - - pp::NetworkListPrivate current_list; - TestCompletionCallback completion_callback; -}; - } // namespace TestNetworkMonitorPrivate::TestNetworkMonitorPrivate(TestingInstance* instance) @@ -87,17 +69,12 @@ void TestNetworkMonitorPrivate::RunTests(const std::string& filter) { RUN_TEST_FORCEASYNC_AND_NOT(Basic, filter); RUN_TEST_FORCEASYNC_AND_NOT(2Monitors, filter); RUN_TEST_FORCEASYNC_AND_NOT(DeleteInCallback, filter); - RUN_TEST_FORCEASYNC_AND_NOT(ListObserver, filter); -} - -std::string TestNetworkMonitorPrivate::VerifyNetworkListResource( - PP_Resource network_list_resource) { - pp::NetworkListPrivate network_list(network_list_resource); - return VerifyNetworkList(network_list); } std::string TestNetworkMonitorPrivate::VerifyNetworkList( - const pp::NetworkListPrivate& network_list) { + PP_Resource network_resource) { + pp::NetworkListPrivate network_list(network_resource); + // Verify that there is at least one network interface. size_t count = network_list.GetCount(); ASSERT_TRUE(count >= 1U); @@ -160,7 +137,7 @@ std::string TestNetworkMonitorPrivate::VerifyNetworkList( const char kFillValue = 123; memset(&addresses.front(), kFillValue, addresses.size() * sizeof(PP_NetAddress_Private)); - int result = interface->GetIpAddresses(network_list.pp_resource(), 0, + int result = interface->GetIpAddresses(network_resource, 0, &addresses.front(), i); ASSERT_EQ(result, static_cast<int>(address_count)); @@ -183,8 +160,7 @@ std::string TestNetworkMonitorPrivate::TestBasic() { ASSERT_EQ(callback_data.completion_callback.WaitForResult(), PP_OK); ASSERT_EQ(callback_data.call_counter, 1); - ASSERT_SUBTEST_SUCCESS( - VerifyNetworkListResource(callback_data.list_resource)); + ASSERT_SUBTEST_SUCCESS(VerifyNetworkList(callback_data.list_resource)); PASS(); } @@ -197,8 +173,7 @@ std::string TestNetworkMonitorPrivate::Test2Monitors() { ASSERT_EQ(callback_data.completion_callback.WaitForResult(), PP_OK); ASSERT_EQ(callback_data.call_counter, 1); - ASSERT_SUBTEST_SUCCESS( - VerifyNetworkListResource(callback_data.list_resource)); + ASSERT_SUBTEST_SUCCESS(VerifyNetworkList(callback_data.list_resource)); CallbackData callback_data_2(instance_->pp_instance()); @@ -207,8 +182,7 @@ std::string TestNetworkMonitorPrivate::Test2Monitors() { ASSERT_EQ(callback_data_2.completion_callback.WaitForResult(), PP_OK); ASSERT_EQ(callback_data_2.call_counter, 1); - ASSERT_SUBTEST_SUCCESS( - VerifyNetworkListResource(callback_data_2.list_resource)); + ASSERT_SUBTEST_SUCCESS(VerifyNetworkList(callback_data_2.list_resource)); PASS(); } @@ -224,15 +198,7 @@ std::string TestNetworkMonitorPrivate::TestDeleteInCallback() { ASSERT_EQ(callback_data.completion_callback.WaitForResult(), PP_OK); ASSERT_EQ(callback_data.call_counter, 1); - ASSERT_SUBTEST_SUCCESS( - VerifyNetworkListResource(callback_data.list_resource)); - - PASS(); -} + ASSERT_SUBTEST_SUCCESS(VerifyNetworkList(callback_data.list_resource)); -std::string TestNetworkMonitorPrivate::TestListObserver() { - TestNetworkListObserver observer(instance_); - ASSERT_EQ(observer.completion_callback.WaitForResult(), PP_OK); - ASSERT_SUBTEST_SUCCESS(VerifyNetworkList(observer.current_list)); PASS(); } diff --git a/ppapi/tests/test_network_monitor_private.h b/ppapi/tests/test_network_monitor_private.h index 38016d2..00a856a 100644 --- a/ppapi/tests/test_network_monitor_private.h +++ b/ppapi/tests/test_network_monitor_private.h @@ -10,10 +10,6 @@ #include "ppapi/c/pp_stdint.h" #include "ppapi/tests/test_case.h" -namespace pp { -class NetworkListPrivate; -} // namespace pp - class TestNetworkMonitorPrivate : public TestCase { public: explicit TestNetworkMonitorPrivate(TestingInstance* instance); @@ -26,10 +22,8 @@ class TestNetworkMonitorPrivate : public TestCase { std::string TestBasic(); std::string Test2Monitors(); std::string TestDeleteInCallback(); - std::string TestListObserver(); - std::string VerifyNetworkListResource(PP_Resource network_resource); - std::string VerifyNetworkList(const pp::NetworkListPrivate& network_list); + std::string VerifyNetworkList(PP_Resource network_resource); }; #endif // PAPPI_TESTS_TEST_NETWORK_MONITOR_PRIVATE_H_ diff --git a/ppapi/utility/private/network_list_observer_private.cc b/ppapi/utility/private/network_list_observer_private.cc deleted file mode 100644 index f41e81b..0000000 --- a/ppapi/utility/private/network_list_observer_private.cc +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) 2012 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 "ppapi/utility/private/network_list_observer_private.h" - -#include "ppapi/cpp/private/network_list_private.h" -#include "ppapi/cpp/module.h" - -namespace pp { - -NetworkListObserverPrivate::NetworkListObserverPrivate( - const InstanceHandle& instance) - : PP_ALLOW_THIS_IN_INITIALIZER_LIST( - monitor_(instance, - &NetworkListObserverPrivate::NetworkListCallbackHandler, - this)) { -} - -NetworkListObserverPrivate::~NetworkListObserverPrivate() { -} - -// static -void NetworkListObserverPrivate::NetworkListCallbackHandler( - void* user_data, - PP_Resource list_resource) { - NetworkListObserverPrivate* object = - static_cast<NetworkListObserverPrivate*>(user_data); - NetworkListPrivate list(list_resource); - object->OnNetworkListChanged(list); - Module::Get()->core()->ReleaseResource(list_resource); -} - -} // namespace pp diff --git a/ppapi/utility/private/network_list_observer_private.h b/ppapi/utility/private/network_list_observer_private.h deleted file mode 100644 index 22e1e78..0000000 --- a/ppapi/utility/private/network_list_observer_private.h +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) 2012 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. - -#ifndef PPAPI_UTILITY_PRIVATE_NETWORK_LIST_OBSERVER_H_ -#define PPAPI_UTILITY_PRIVATE_NETWORK_LIST_OBSERVER_H_ - -#include "ppapi/cpp/private/network_monitor_private.h" - -namespace pp { - -class NetworkListPrivate; - -/// <code>NetworkListObserver</code> is a wrapper for -/// <code>pp::NetworkMonitorPrivate</code> that makes it easier to -/// handle network list update notifications. A child class must -/// implement the <code>OnNetworkListChanged()</code> method. That -/// method will be called once after the object is created and then -/// every time network configuration changes. -class NetworkListObserverPrivate { - public: - explicit NetworkListObserverPrivate(const InstanceHandle& instance); - virtual ~NetworkListObserverPrivate(); - - protected: - /// Called once after this object is created and later every time - /// network configuration changes. Child classes must implement this - /// method. - /// - /// @param[in] list The current list of network interfaces. - virtual void OnNetworkListChanged(const NetworkListPrivate& list) = 0; - - private: - static void NetworkListCallbackHandler(void* user_data, - PP_Resource list_resource); - - NetworkMonitorPrivate monitor_; -}; - -} // namespace pp - -#endif // PPAPI_UTILITY_PRIVATE_NETWORK_LIST_OBSERVER_H_ |