Skip to content

Commit

Permalink
Move Tuple to base namespace.
Browse files Browse the repository at this point in the history
Namespace change only, no functionality change.

The only non-search-and-replace change is in generate_gmock_mutant.py which changes some line wrapping logic for the generated gmock_mutant header.

NOPRESUBMIT=true
(No presubmit due to long lines in the generated gmock_mutant.h header).
R=sky

Review URL: https://codereview.chromium.org/1159553007

Cr-Commit-Position: refs/heads/master@{#332058}
  • Loading branch information
brettw authored and Commit bot committed May 29, 2015
1 parent e124019 commit d5ca2bc
Show file tree
Hide file tree
Showing 103 changed files with 2,923 additions and 2,685 deletions.
6 changes: 3 additions & 3 deletions base/observer_list_threadsafe.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ class ObserverListThreadSafe
void Notify(const tracked_objects::Location& from_here,
Method m,
const Params&... params) {
UnboundMethod<ObserverType, Method, Tuple<Params...>> method(
m, MakeTuple(params...));
UnboundMethod<ObserverType, Method, base::Tuple<Params...>> method(
m, base::MakeTuple(params...));

base::AutoLock lock(list_lock_);
for (const auto& entry : observer_lists_) {
Expand All @@ -182,7 +182,7 @@ class ObserverListThreadSafe
from_here,
base::Bind(
&ObserverListThreadSafe<ObserverType>::template NotifyWrapper<
Method, Tuple<Params...>>,
Method, base::Tuple<Params...>>,
this, context, method));
}
}
Expand Down
10 changes: 7 additions & 3 deletions base/tuple.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

#include "base/bind_helpers.h"

namespace base {

// Index sequences
//
// Minimal clone of the similarly-named C++14 functionality.
Expand Down Expand Up @@ -181,9 +183,9 @@ struct TupleLeaf {
// Allows accessing an arbitrary tuple element by index.
//
// Example usage:
// Tuple<int, double> t2;
// get<0>(t2) = 42;
// get<1>(t2) = 3.14;
// base::Tuple<int, double> t2;
// base::get<0>(t2) = 42;
// base::get<1>(t2) = 3.14;

template <size_t I, typename T>
T& get(TupleLeaf<I, T>& leaf) {
Expand Down Expand Up @@ -329,4 +331,6 @@ inline void DispatchToMethod(ObjT* obj,
MakeIndexSequence<sizeof...(OutTs)>());
}

} // namespace base

#endif // BASE_TUPLE_H_
23 changes: 14 additions & 9 deletions base/tuple_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include "base/compiler_specific.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace base {

namespace {

void DoAdd(int a, int b, int c, int* res) {
Expand All @@ -30,14 +32,15 @@ struct Addz {
} // namespace

TEST(TupleTest, Basic) {
Tuple<> t0 = MakeTuple();
base::Tuple<> t0 = base::MakeTuple();
ALLOW_UNUSED_LOCAL(t0);
Tuple<int> t1(1);
Tuple<int, const char*> t2 = MakeTuple(1, static_cast<const char*>("wee"));
Tuple<int, int, int> t3(1, 2, 3);
Tuple<int, int, int, int*> t4(1, 2, 3, &get<0>(t1));
Tuple<int, int, int, int, int*> t5(1, 2, 3, 4, &get<0>(t4));
Tuple<int, int, int, int, int, int*> t6(1, 2, 3, 4, 5, &get<0>(t4));
base::Tuple<int> t1(1);
base::Tuple<int, const char*> t2 =
base::MakeTuple(1, static_cast<const char*>("wee"));
base::Tuple<int, int, int> t3(1, 2, 3);
base::Tuple<int, int, int, int*> t4(1, 2, 3, &get<0>(t1));
base::Tuple<int, int, int, int, int*> t5(1, 2, 3, 4, &get<0>(t4));
base::Tuple<int, int, int, int, int, int*> t6(1, 2, 3, 4, 5, &get<0>(t4));

EXPECT_EQ(1, get<0>(t1));
EXPECT_EQ(1, get<0>(t2));
Expand All @@ -62,7 +65,7 @@ TEST(TupleTest, Basic) {
EXPECT_EQ(6, get<0>(t1));

int res = 0;
DispatchToFunction(&DoAdd, MakeTuple(9, 8, 7, &res));
DispatchToFunction(&DoAdd, base::MakeTuple(9, 8, 7, &res));
EXPECT_EQ(24, res);

Addy addy;
Expand Down Expand Up @@ -108,7 +111,7 @@ TEST(TupleTest, Copying) {
bool res = false;

// Creating the tuple should copy the class to store internally in the tuple.
Tuple<CopyLogger, CopyLogger*, bool*> tuple(logger, &logger, &res);
base::Tuple<CopyLogger, CopyLogger*, bool*> tuple(logger, &logger, &res);
get<1>(tuple) = &get<0>(tuple);
EXPECT_EQ(2, CopyLogger::TimesConstructed);
EXPECT_EQ(1, CopyLogger::TimesCopied);
Expand All @@ -127,3 +130,5 @@ TEST(TupleTest, Copying) {
EXPECT_EQ(3, CopyLogger::TimesConstructed);
EXPECT_EQ(2, CopyLogger::TimesCopied);
}

} // namespace base
2 changes: 1 addition & 1 deletion chrome/browser/apps/app_shim/app_shim_host_mac_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class AppShimHostTest : public testing::Test,
EXPECT_EQ(AppShimMsg_LaunchApp_Done::ID, message->type());
AppShimMsg_LaunchApp_Done::Param param;
AppShimMsg_LaunchApp_Done::Read(message, &param);
return get<0>(param);
return base::get<0>(param);
}

void SimulateDisconnect() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ void GetPartOfMessageArguments(IPC::Message* message,
ExtensionMsg_MessageInvoke::Param* param) {
ASSERT_EQ(ExtensionMsg_MessageInvoke::ID, message->type());
ASSERT_TRUE(ExtensionMsg_MessageInvoke::Read(message, param));
ASSERT_GE(get<3>(*param).GetSize(), 2u);
ASSERT_GE(base::get<3>(*param).GetSize(), 2u);
const base::Value* value = NULL;
ASSERT_TRUE(get<3>(*param).Get(1, &value));
ASSERT_TRUE(base::get<3>(*param).Get(1, &value));
const base::ListValue* list = NULL;
ASSERT_TRUE(value->GetAsList(&list));
ASSERT_EQ(1u, list->GetSize());
Expand Down Expand Up @@ -925,7 +925,7 @@ TEST_P(ExtensionWebRequestHeaderModificationTest, TestModifications) {
continue;
ExtensionMsg_MessageInvoke::Param message_tuple;
ExtensionMsg_MessageInvoke::Read(message, &message_tuple);
base::ListValue& args = get<3>(message_tuple);
base::ListValue& args = base::get<3>(message_tuple);

std::string event_name;
if (!args.GetString(0, &event_name) ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ bool ChromePasswordManagerClientTest::WasLoggingActivationMessageSent(
process()->sink().GetFirstMessageMatching(kMsgID);
if (!message)
return false;
Tuple<bool> param;
base::Tuple<bool> param;
AutofillMsg_SetLoggingState::Read(message, &param);
*activation_flag = get<0>(param);
*activation_flag = base::get<0>(param);
process()->sink().ClearMessages();
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,9 @@ class ClientSideDetectionHostTest : public ChromeRenderViewHostTestHarness {
SafeBrowsingMsg_StartPhishingDetection::ID);
if (url) {
ASSERT_TRUE(msg);
Tuple<GURL> actual_url;
base::Tuple<GURL> actual_url;
SafeBrowsingMsg_StartPhishingDetection::Read(msg, &actual_url);
EXPECT_EQ(*url, get<0>(actual_url));
EXPECT_EQ(*url, base::get<0>(actual_url));
EXPECT_EQ(rvh()->GetRoutingID(), msg->routing_id());
process()->sink().ClearMessages();
} else {
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/search/instant_service_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ TEST_F(InstantServiceEnabledTest, SendsSearchURLsToRenderer) {
ASSERT_TRUE(msg);
ChromeViewMsg_SetSearchURLs::Param params;
ChromeViewMsg_SetSearchURLs::Read(msg, &params);
std::vector<GURL> search_urls = get<0>(params);
GURL new_tab_page_url = get<1>(params);
std::vector<GURL> search_urls = base::get<0>(params);
GURL new_tab_page_url = base::get<1>(params);
EXPECT_EQ(2U, search_urls.size());
EXPECT_EQ("https://www.google.com/alt#quux=", search_urls[0].spec());
EXPECT_EQ("https://www.google.com/url?bar=", search_urls[1].spec());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ IN_PROC_BROWSER_TEST_F(SpellCheckMessageFilterMacBrowserTest,
SpellCheckMsg_RespondTextCheck::Param params;
bool ok = SpellCheckMsg_RespondTextCheck::Read(
target->sent_messages_[0], &params);
std::vector<SpellCheckResult> sent_results = get<1>(params);
std::vector<SpellCheckResult> sent_results = base::get<1>(params);

EXPECT_TRUE(ok);
EXPECT_EQ(1U, sent_results.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ TEST(SpellCheckMessageFilterTest, OnTextCheckCompleteTestCustomDictionary) {
SpellCheckMsg_RespondSpellingService::Param params;
bool ok = SpellCheckMsg_RespondSpellingService::Read(
filter->sent_messages[0], &params);
int sent_identifier = get<0>(params);
bool sent_success = get<1>(params);
base::string16 sent_text = get<2>(params);
std::vector<SpellCheckResult> sent_results = get<3>(params);
int sent_identifier = base::get<0>(params);
bool sent_success = base::get<1>(params);
base::string16 sent_text = base::get<2>(params);
std::vector<SpellCheckResult> sent_results = base::get<3>(params);
EXPECT_TRUE(ok);
EXPECT_EQ(kCallbackId, sent_identifier);
EXPECT_EQ(kSuccess, sent_success);
Expand Down Expand Up @@ -135,8 +135,8 @@ TEST(SpellCheckMessageFilterTest, OnTextCheckCompleteTest) {
SpellCheckMsg_RespondSpellingService::Param params;
bool ok = SpellCheckMsg_RespondSpellingService::Read(
filter->sent_messages[0], & params);
base::string16 sent_text = get<2>(params);
std::vector<SpellCheckResult> sent_results = get<3>(params);
base::string16 sent_text = base::get<2>(params);
std::vector<SpellCheckResult> sent_results = base::get<3>(params);
EXPECT_TRUE(ok);
EXPECT_EQ(static_cast<size_t>(2), sent_results.size());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,14 @@ class TranslateManagerRenderViewHostTest
ChromeViewMsg_TranslatePage::ID);
if (!message)
return false;
Tuple<int, std::string, std::string, std::string> translate_param;
base::Tuple<int, std::string, std::string, std::string> translate_param;
ChromeViewMsg_TranslatePage::Read(message, &translate_param);
// Ignore get<0>(translate_param) which is the page seq no.
// Ignore get<1>(translate_param) which is the script injected in the page.
if (original_lang)
*original_lang = get<2>(translate_param);
*original_lang = base::get<2>(translate_param);
if (target_lang)
*target_lang = get<3>(translate_param);
*target_lang = base::get<3>(translate_param);
return true;
}

Expand Down
12 changes: 6 additions & 6 deletions chrome/browser/ui/search/instant_search_prerenderer_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -529,13 +529,13 @@ TEST_F(TestUsePrerenderPage, SetEmbeddedSearchRequestParams) {
ASSERT_TRUE(message);

// Verify the IPC message params.
Tuple<base::string16, EmbeddedSearchRequestParams> params;
base::Tuple<base::string16, EmbeddedSearchRequestParams> params;
ChromeViewMsg_SearchBoxSubmit::Read(message, &params);
EXPECT_EQ("foo", base::UTF16ToASCII(get<0>(params)));
EXPECT_EQ("f", base::UTF16ToASCII(get<1>(params).original_query));
EXPECT_EQ("utf-8", base::UTF16ToASCII(get<1>(params).input_encoding));
EXPECT_EQ("", base::UTF16ToASCII(get<1>(params).rlz_parameter_value));
EXPECT_EQ("foo", base::UTF16ToASCII(base::get<0>(params)));
EXPECT_EQ("f", base::UTF16ToASCII(base::get<1>(params).original_query));
EXPECT_EQ("utf-8", base::UTF16ToASCII(base::get<1>(params).input_encoding));
EXPECT_EQ("", base::UTF16ToASCII(base::get<1>(params).rlz_parameter_value));
EXPECT_EQ("chrome...0",
base::UTF16ToASCII(get<1>(params).assisted_query_stats));
base::UTF16ToASCII(base::get<1>(params).assisted_query_stats));
}
#endif
5 changes: 3 additions & 2 deletions chrome/browser/ui/search/search_ipc_router_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,11 @@ class SearchIPCRouterTest : public BrowserWithTestWindowTest {
const IPC::Message* message = process()->sink().GetFirstMessageMatching(
ChromeViewMsg_SearchBoxSetDisplayInstantResults::ID);
EXPECT_NE(static_cast<const IPC::Message*>(NULL), message);
Tuple<bool> display_instant_results_param;
base::Tuple<bool> display_instant_results_param;
ChromeViewMsg_SearchBoxSetDisplayInstantResults::Read(
message, &display_instant_results_param);
EXPECT_EQ(expected_param_value, get<0>(display_instant_results_param));
EXPECT_EQ(expected_param_value,
base::get<0>(display_instant_results_param));
}

MockSearchIPCRouterDelegate* mock_delegate() { return &delegate_; }
Expand Down
24 changes: 12 additions & 12 deletions chrome/browser/ui/search/search_tab_helper_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ TEST_F(SearchTabHelperTest, OnChromeIdentityCheckMatch) {

ChromeViewMsg_ChromeIdentityCheckResult::Param params;
ChromeViewMsg_ChromeIdentityCheckResult::Read(message, &params);
EXPECT_EQ(test_identity, get<0>(params));
ASSERT_TRUE(get<1>(params));
EXPECT_EQ(test_identity, base::get<0>(params));
ASSERT_TRUE(base::get<1>(params));
}

TEST_F(SearchTabHelperTest, OnChromeIdentityCheckMatchSlightlyDifferentGmail) {
Expand All @@ -213,8 +213,8 @@ TEST_F(SearchTabHelperTest, OnChromeIdentityCheckMatchSlightlyDifferentGmail) {

ChromeViewMsg_ChromeIdentityCheckResult::Param params;
ChromeViewMsg_ChromeIdentityCheckResult::Read(message, &params);
EXPECT_EQ(test_identity, get<0>(params));
ASSERT_TRUE(get<1>(params));
EXPECT_EQ(test_identity, base::get<0>(params));
ASSERT_TRUE(base::get<1>(params));
}

TEST_F(SearchTabHelperTest, OnChromeIdentityCheckMatchSlightlyDifferentGmail2) {
Expand All @@ -237,8 +237,8 @@ TEST_F(SearchTabHelperTest, OnChromeIdentityCheckMatchSlightlyDifferentGmail2) {

ChromeViewMsg_ChromeIdentityCheckResult::Param params;
ChromeViewMsg_ChromeIdentityCheckResult::Read(message, &params);
EXPECT_EQ(test_identity, get<0>(params));
ASSERT_TRUE(get<1>(params));
EXPECT_EQ(test_identity, base::get<0>(params));
ASSERT_TRUE(base::get<1>(params));
}

TEST_F(SearchTabHelperTest, OnChromeIdentityCheckMismatch) {
Expand All @@ -257,8 +257,8 @@ TEST_F(SearchTabHelperTest, OnChromeIdentityCheckMismatch) {

ChromeViewMsg_ChromeIdentityCheckResult::Param params;
ChromeViewMsg_ChromeIdentityCheckResult::Read(message, &params);
EXPECT_EQ(test_identity, get<0>(params));
ASSERT_FALSE(get<1>(params));
EXPECT_EQ(test_identity, base::get<0>(params));
ASSERT_FALSE(base::get<1>(params));
}

TEST_F(SearchTabHelperTest, OnChromeIdentityCheckSignedOutMismatch) {
Expand All @@ -277,8 +277,8 @@ TEST_F(SearchTabHelperTest, OnChromeIdentityCheckSignedOutMismatch) {

ChromeViewMsg_ChromeIdentityCheckResult::Param params;
ChromeViewMsg_ChromeIdentityCheckResult::Read(message, &params);
EXPECT_EQ(test_identity, get<0>(params));
ASSERT_FALSE(get<1>(params));
EXPECT_EQ(test_identity, base::get<0>(params));
ASSERT_FALSE(base::get<1>(params));
}

TEST_F(SearchTabHelperTest, OnHistorySyncCheckSyncing) {
Expand All @@ -296,7 +296,7 @@ TEST_F(SearchTabHelperTest, OnHistorySyncCheckSyncing) {

ChromeViewMsg_HistorySyncCheckResult::Param params;
ChromeViewMsg_HistorySyncCheckResult::Read(message, &params);
ASSERT_TRUE(get<0>(params));
ASSERT_TRUE(base::get<0>(params));
}

TEST_F(SearchTabHelperTest, OnHistorySyncCheckNotSyncing) {
Expand All @@ -314,7 +314,7 @@ TEST_F(SearchTabHelperTest, OnHistorySyncCheckNotSyncing) {

ChromeViewMsg_HistorySyncCheckResult::Param params;
ChromeViewMsg_HistorySyncCheckResult::Read(message, &params);
ASSERT_FALSE(get<0>(params));
ASSERT_FALSE(base::get<0>(params));
}

class TabTitleObserver : public content::WebContentsObserver {
Expand Down
2 changes: 1 addition & 1 deletion chrome/common/chrome_utility_messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#if defined(OS_WIN)
// A vector of filters, each being a Tuple containing a display string (i.e.
// "Text Files") and a filter pattern (i.e. "*.txt").
typedef std::vector<Tuple<base::string16, base::string16>>
typedef std::vector<base::Tuple<base::string16, base::string16>>
GetOpenFileNameFilter;
#endif // OS_WIN

Expand Down
14 changes: 7 additions & 7 deletions chrome/renderer/autofill/autofill_renderer_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ using blink::WebVector;

namespace autofill {

typedef Tuple<int, autofill::FormData, autofill::FormFieldData, gfx::RectF>
AutofillQueryParam;
typedef base::Tuple<int, autofill::FormData, autofill::FormFieldData,
gfx::RectF> AutofillQueryParam;

class AutofillRendererTest : public ChromeRenderViewTest {
public:
Expand Down Expand Up @@ -86,7 +86,7 @@ TEST_F(AutofillRendererTest, SendForms) {
ASSERT_NE(nullptr, message);
AutofillHostMsg_FormsSeen::Param params;
AutofillHostMsg_FormsSeen::Read(message, &params);
std::vector<FormData> forms = get<0>(params);
std::vector<FormData> forms = base::get<0>(params);
ASSERT_EQ(1UL, forms.size());
ASSERT_EQ(4UL, forms[0].fields.size());

Expand Down Expand Up @@ -149,7 +149,7 @@ TEST_F(AutofillRendererTest, SendForms) {
AutofillHostMsg_FormsSeen::ID);
ASSERT_NE(nullptr, message);
AutofillHostMsg_FormsSeen::Read(message, &params);
forms = get<0>(params);
forms = base::get<0>(params);
ASSERT_EQ(1UL, forms.size());
ASSERT_EQ(3UL, forms[0].fields.size());

Expand Down Expand Up @@ -181,7 +181,7 @@ TEST_F(AutofillRendererTest, EnsureNoFormSeenIfTooFewFields) {
ASSERT_NE(nullptr, message);
AutofillHostMsg_FormsSeen::Param params;
AutofillHostMsg_FormsSeen::Read(message, &params);
const std::vector<FormData>& forms = get<0>(params);
const std::vector<FormData>& forms = base::get<0>(params);
ASSERT_EQ(0UL, forms.size());
}

Expand Down Expand Up @@ -214,7 +214,7 @@ TEST_F(AutofillRendererTest, DynamicallyAddedUnownedFormElements) {
ASSERT_NE(nullptr, message);
AutofillHostMsg_FormsSeen::Param params;
AutofillHostMsg_FormsSeen::Read(message, &params);
std::vector<FormData> forms = get<0>(params);
std::vector<FormData> forms = base::get<0>(params);
ASSERT_EQ(1UL, forms.size());
ASSERT_EQ(7UL, forms[0].fields.size());

Expand All @@ -227,7 +227,7 @@ TEST_F(AutofillRendererTest, DynamicallyAddedUnownedFormElements) {
AutofillHostMsg_FormsSeen::ID);
ASSERT_NE(nullptr, message);
AutofillHostMsg_FormsSeen::Read(message, &params);
forms = get<0>(params);
forms = base::get<0>(params);
ASSERT_EQ(1UL, forms.size());
ASSERT_EQ(9UL, forms[0].fields.size());

Expand Down
Loading

0 comments on commit d5ca2bc

Please sign in to comment.