Skip to content

Commit

Permalink
Revert 127797 - Add NetworkListObserver utility class.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
sergeyu@chromium.org committed Mar 20, 2012
1 parent 061239c commit 6de9070
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 148 deletions.
2 changes: 0 additions & 2 deletions chrome/test/ui/ppapi_uitest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
17 changes: 7 additions & 10 deletions ppapi/cpp/private/network_list_private.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ template <> const char* interface_name<PPB_NetworkList_Private>() {

} // namespace

NetworkListPrivate::NetworkListPrivate() {
}

NetworkListPrivate::NetworkListPrivate(PP_Resource resource)
: Resource(resource) {
}
Expand All @@ -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,
Expand All @@ -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(
Expand All @@ -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;

Expand Down Expand Up @@ -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,
Expand All @@ -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(
Expand Down
15 changes: 7 additions & 8 deletions ppapi/cpp/private/network_list_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,41 +15,40 @@ namespace pp {

class NetworkListPrivate : public Resource {
public:
NetworkListPrivate();
explicit NetworkListPrivate(PP_Resource resource);

/// Returns true if the required interface is available.
static bool IsAvailable();

/// @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
Expand Down
2 changes: 0 additions & 2 deletions ppapi/ppapi_sources.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
52 changes: 9 additions & 43 deletions ppapi/tests/test_network_monitor_private.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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)
Expand All @@ -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);
Expand Down Expand Up @@ -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));

Expand All @@ -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();
}
Expand All @@ -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());

Expand All @@ -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();
}
Expand All @@ -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();
}
8 changes: 1 addition & 7 deletions ppapi/tests/test_network_monitor_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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_
34 changes: 0 additions & 34 deletions ppapi/utility/private/network_list_observer_private.cc

This file was deleted.

42 changes: 0 additions & 42 deletions ppapi/utility/private/network_list_observer_private.h

This file was deleted.

0 comments on commit 6de9070

Please sign in to comment.