Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <algorithm> | 5 #include <algorithm> |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
| 9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 1391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1402 CHECK(StartTestServer()); | 1402 CHECK(StartTestServer()); |
| 1403 std::string download_url = test_server()->GetURL("slow?0").spec(); | 1403 std::string download_url = test_server()->GetURL("slow?0").spec(); |
| 1404 GoOnTheRecord(); | 1404 GoOnTheRecord(); |
| 1405 | 1405 |
| 1406 scoped_ptr<base::Value> result(RunFunctionAndReturnResult( | 1406 scoped_ptr<base::Value> result(RunFunctionAndReturnResult( |
| 1407 new DownloadsDownloadFunction(), base::StringPrintf( | 1407 new DownloadsDownloadFunction(), base::StringPrintf( |
| 1408 "[{\"url\": \"%s\"}]", download_url.c_str()))); | 1408 "[{\"url\": \"%s\"}]", download_url.c_str()))); |
| 1409 ASSERT_TRUE(result.get()); | 1409 ASSERT_TRUE(result.get()); |
| 1410 int result_id = -1; | 1410 int result_id = -1; |
| 1411 ASSERT_TRUE(result->GetAsInteger(&result_id)); | 1411 ASSERT_TRUE(result->GetAsInteger(&result_id)); |
| 1412 DownloadItem* item = GetCurrentManager()->GetActiveDownloadItem(result_id); | 1412 DownloadItem* item = GetCurrentManager()->GetDownload(result_id); |
| 1413 if (!item) item = GetCurrentManager()->GetDownloadItem(result_id); | 1413 if (!item) item = GetCurrentManager()->GetDownload(result_id); |
|
Randy Smith (Not in Mondays)
2012/09/11 19:02:21
I'm guessing that you query-replaced and didn't re
benjhayden
2012/09/12 18:17:25
Done.
| |
| 1414 ASSERT_TRUE(item); | 1414 ASSERT_TRUE(item); |
| 1415 ScopedCancellingItem canceller(item); | 1415 ScopedCancellingItem canceller(item); |
| 1416 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 1416 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
| 1417 | 1417 |
| 1418 ASSERT_TRUE(WaitFor(events::kOnDownloadCreated, | 1418 ASSERT_TRUE(WaitFor(events::kOnDownloadCreated, |
| 1419 base::StringPrintf("[{\"danger\": \"safe\"," | 1419 base::StringPrintf("[{\"danger\": \"safe\"," |
| 1420 " \"incognito\": false," | 1420 " \"incognito\": false," |
| 1421 " \"mime\": \"text/plain\"," | 1421 " \"mime\": \"text/plain\"," |
| 1422 " \"paused\": false," | 1422 " \"paused\": false," |
| 1423 " \"url\": \"%s\"}]", | 1423 " \"url\": \"%s\"}]", |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 1443 CHECK(StartTestServer()); | 1443 CHECK(StartTestServer()); |
| 1444 GoOffTheRecord(); | 1444 GoOffTheRecord(); |
| 1445 std::string download_url = test_server()->GetURL("slow?0").spec(); | 1445 std::string download_url = test_server()->GetURL("slow?0").spec(); |
| 1446 | 1446 |
| 1447 scoped_ptr<base::Value> result(RunFunctionAndReturnResult( | 1447 scoped_ptr<base::Value> result(RunFunctionAndReturnResult( |
| 1448 new DownloadsDownloadFunction(), base::StringPrintf( | 1448 new DownloadsDownloadFunction(), base::StringPrintf( |
| 1449 "[{\"url\": \"%s\"}]", download_url.c_str()))); | 1449 "[{\"url\": \"%s\"}]", download_url.c_str()))); |
| 1450 ASSERT_TRUE(result.get()); | 1450 ASSERT_TRUE(result.get()); |
| 1451 int result_id = -1; | 1451 int result_id = -1; |
| 1452 ASSERT_TRUE(result->GetAsInteger(&result_id)); | 1452 ASSERT_TRUE(result->GetAsInteger(&result_id)); |
| 1453 DownloadItem* item = GetCurrentManager()->GetActiveDownloadItem(result_id); | 1453 DownloadItem* item = GetCurrentManager()->GetDownload(result_id); |
| 1454 if (!item) item = GetCurrentManager()->GetDownloadItem(result_id); | 1454 if (!item) item = GetCurrentManager()->GetDownload(result_id); |
| 1455 ASSERT_TRUE(item); | 1455 ASSERT_TRUE(item); |
| 1456 ScopedCancellingItem canceller(item); | 1456 ScopedCancellingItem canceller(item); |
| 1457 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 1457 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
| 1458 | 1458 |
| 1459 ASSERT_TRUE(WaitFor(events::kOnDownloadCreated, | 1459 ASSERT_TRUE(WaitFor(events::kOnDownloadCreated, |
| 1460 base::StringPrintf("[{\"danger\": \"safe\"," | 1460 base::StringPrintf("[{\"danger\": \"safe\"," |
| 1461 " \"incognito\": true," | 1461 " \"incognito\": true," |
| 1462 " \"mime\": \"text/plain\"," | 1462 " \"mime\": \"text/plain\"," |
| 1463 " \"paused\": false," | 1463 " \"paused\": false," |
| 1464 " \"url\": \"%s\"}]", | 1464 " \"url\": \"%s\"}]", |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1597 CHECK(StartTestServer()); | 1597 CHECK(StartTestServer()); |
| 1598 std::string download_url = test_server()->GetURL("slow?0#fragment").spec(); | 1598 std::string download_url = test_server()->GetURL("slow?0#fragment").spec(); |
| 1599 GoOnTheRecord(); | 1599 GoOnTheRecord(); |
| 1600 | 1600 |
| 1601 scoped_ptr<base::Value> result(RunFunctionAndReturnResult( | 1601 scoped_ptr<base::Value> result(RunFunctionAndReturnResult( |
| 1602 new DownloadsDownloadFunction(), base::StringPrintf( | 1602 new DownloadsDownloadFunction(), base::StringPrintf( |
| 1603 "[{\"url\": \"%s\"}]", download_url.c_str()))); | 1603 "[{\"url\": \"%s\"}]", download_url.c_str()))); |
| 1604 ASSERT_TRUE(result.get()); | 1604 ASSERT_TRUE(result.get()); |
| 1605 int result_id = -1; | 1605 int result_id = -1; |
| 1606 ASSERT_TRUE(result->GetAsInteger(&result_id)); | 1606 ASSERT_TRUE(result->GetAsInteger(&result_id)); |
| 1607 DownloadItem* item = GetCurrentManager()->GetActiveDownloadItem(result_id); | 1607 DownloadItem* item = GetCurrentManager()->GetDownload(result_id); |
| 1608 if (!item) item = GetCurrentManager()->GetDownloadItem(result_id); | 1608 if (!item) item = GetCurrentManager()->GetDownload(result_id); |
| 1609 ASSERT_TRUE(item); | 1609 ASSERT_TRUE(item); |
| 1610 ScopedCancellingItem canceller(item); | 1610 ScopedCancellingItem canceller(item); |
| 1611 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 1611 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
| 1612 | 1612 |
| 1613 ASSERT_TRUE(WaitFor(events::kOnDownloadCreated, | 1613 ASSERT_TRUE(WaitFor(events::kOnDownloadCreated, |
| 1614 base::StringPrintf("[{\"danger\": \"safe\"," | 1614 base::StringPrintf("[{\"danger\": \"safe\"," |
| 1615 " \"incognito\": false," | 1615 " \"incognito\": false," |
| 1616 " \"mime\": \"text/plain\"," | 1616 " \"mime\": \"text/plain\"," |
| 1617 " \"paused\": false," | 1617 " \"paused\": false," |
| 1618 " \"url\": \"%s\"}]", | 1618 " \"url\": \"%s\"}]", |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 1638 std::string download_url = "data:text/plain,hello"; | 1638 std::string download_url = "data:text/plain,hello"; |
| 1639 GoOnTheRecord(); | 1639 GoOnTheRecord(); |
| 1640 | 1640 |
| 1641 scoped_ptr<base::Value> result(RunFunctionAndReturnResult( | 1641 scoped_ptr<base::Value> result(RunFunctionAndReturnResult( |
| 1642 new DownloadsDownloadFunction(), base::StringPrintf( | 1642 new DownloadsDownloadFunction(), base::StringPrintf( |
| 1643 "[{\"url\": \"%s\"," | 1643 "[{\"url\": \"%s\"," |
| 1644 " \"filename\": \"data.txt\"}]", download_url.c_str()))); | 1644 " \"filename\": \"data.txt\"}]", download_url.c_str()))); |
| 1645 ASSERT_TRUE(result.get()); | 1645 ASSERT_TRUE(result.get()); |
| 1646 int result_id = -1; | 1646 int result_id = -1; |
| 1647 ASSERT_TRUE(result->GetAsInteger(&result_id)); | 1647 ASSERT_TRUE(result->GetAsInteger(&result_id)); |
| 1648 DownloadItem* item = GetCurrentManager()->GetActiveDownloadItem(result_id); | 1648 DownloadItem* item = GetCurrentManager()->GetDownload(result_id); |
| 1649 if (!item) item = GetCurrentManager()->GetDownloadItem(result_id); | 1649 if (!item) item = GetCurrentManager()->GetDownload(result_id); |
| 1650 ASSERT_TRUE(item); | 1650 ASSERT_TRUE(item); |
| 1651 ScopedCancellingItem canceller(item); | 1651 ScopedCancellingItem canceller(item); |
| 1652 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 1652 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
| 1653 | 1653 |
| 1654 ASSERT_TRUE(WaitFor(events::kOnDownloadCreated, | 1654 ASSERT_TRUE(WaitFor(events::kOnDownloadCreated, |
| 1655 base::StringPrintf("[{\"danger\": \"safe\"," | 1655 base::StringPrintf("[{\"danger\": \"safe\"," |
| 1656 " \"incognito\": false," | 1656 " \"incognito\": false," |
| 1657 " \"mime\": \"text/plain\"," | 1657 " \"mime\": \"text/plain\"," |
| 1658 " \"paused\": false," | 1658 " \"paused\": false," |
| 1659 " \"url\": \"%s\"}]", | 1659 " \"url\": \"%s\"}]", |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 1682 download_url += "C:/"; | 1682 download_url += "C:/"; |
| 1683 #endif | 1683 #endif |
| 1684 | 1684 |
| 1685 scoped_ptr<base::Value> result(RunFunctionAndReturnResult( | 1685 scoped_ptr<base::Value> result(RunFunctionAndReturnResult( |
| 1686 new DownloadsDownloadFunction(), base::StringPrintf( | 1686 new DownloadsDownloadFunction(), base::StringPrintf( |
| 1687 "[{\"url\": \"%s\"," | 1687 "[{\"url\": \"%s\"," |
| 1688 " \"filename\": \"file.txt\"}]", download_url.c_str()))); | 1688 " \"filename\": \"file.txt\"}]", download_url.c_str()))); |
| 1689 ASSERT_TRUE(result.get()); | 1689 ASSERT_TRUE(result.get()); |
| 1690 int result_id = -1; | 1690 int result_id = -1; |
| 1691 ASSERT_TRUE(result->GetAsInteger(&result_id)); | 1691 ASSERT_TRUE(result->GetAsInteger(&result_id)); |
| 1692 DownloadItem* item = GetCurrentManager()->GetActiveDownloadItem(result_id); | 1692 DownloadItem* item = GetCurrentManager()->GetDownload(result_id); |
| 1693 if (!item) item = GetCurrentManager()->GetDownloadItem(result_id); | 1693 if (!item) item = GetCurrentManager()->GetDownload(result_id); |
| 1694 ASSERT_TRUE(item); | 1694 ASSERT_TRUE(item); |
| 1695 ScopedCancellingItem canceller(item); | 1695 ScopedCancellingItem canceller(item); |
| 1696 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 1696 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
| 1697 | 1697 |
| 1698 ASSERT_TRUE(WaitFor(events::kOnDownloadCreated, | 1698 ASSERT_TRUE(WaitFor(events::kOnDownloadCreated, |
| 1699 base::StringPrintf("[{\"danger\": \"safe\"," | 1699 base::StringPrintf("[{\"danger\": \"safe\"," |
| 1700 " \"incognito\": false," | 1700 " \"incognito\": false," |
| 1701 " \"mime\": \"text/html\"," | 1701 " \"mime\": \"text/html\"," |
| 1702 " \"paused\": false," | 1702 " \"paused\": false," |
| 1703 " \"url\": \"%s\"}]", | 1703 " \"url\": \"%s\"}]", |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 1727 GoOnTheRecord(); | 1727 GoOnTheRecord(); |
| 1728 | 1728 |
| 1729 scoped_ptr<base::Value> result(RunFunctionAndReturnResult( | 1729 scoped_ptr<base::Value> result(RunFunctionAndReturnResult( |
| 1730 new DownloadsDownloadFunction(), base::StringPrintf( | 1730 new DownloadsDownloadFunction(), base::StringPrintf( |
| 1731 "[{\"url\": \"%s\"," | 1731 "[{\"url\": \"%s\"," |
| 1732 " \"filename\": \"auth-basic-fail.txt\"}]", | 1732 " \"filename\": \"auth-basic-fail.txt\"}]", |
| 1733 download_url.c_str()))); | 1733 download_url.c_str()))); |
| 1734 ASSERT_TRUE(result.get()); | 1734 ASSERT_TRUE(result.get()); |
| 1735 int result_id = -1; | 1735 int result_id = -1; |
| 1736 ASSERT_TRUE(result->GetAsInteger(&result_id)); | 1736 ASSERT_TRUE(result->GetAsInteger(&result_id)); |
| 1737 DownloadItem* item = GetCurrentManager()->GetActiveDownloadItem(result_id); | 1737 DownloadItem* item = GetCurrentManager()->GetDownload(result_id); |
| 1738 if (!item) item = GetCurrentManager()->GetDownloadItem(result_id); | 1738 if (!item) item = GetCurrentManager()->GetDownload(result_id); |
| 1739 ASSERT_TRUE(item); | 1739 ASSERT_TRUE(item); |
| 1740 ScopedCancellingItem canceller(item); | 1740 ScopedCancellingItem canceller(item); |
| 1741 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 1741 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
| 1742 | 1742 |
| 1743 ASSERT_TRUE(WaitForInterruption(item, 30, base::StringPrintf( | 1743 ASSERT_TRUE(WaitForInterruption(item, 30, base::StringPrintf( |
| 1744 "[{\"danger\": \"safe\"," | 1744 "[{\"danger\": \"safe\"," |
| 1745 " \"incognito\": false," | 1745 " \"incognito\": false," |
| 1746 " \"mime\": \"text/html\"," | 1746 " \"mime\": \"text/html\"," |
| 1747 " \"paused\": false," | 1747 " \"paused\": false," |
| 1748 " \"url\": \"%s\"}]", | 1748 " \"url\": \"%s\"}]", |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 1762 new DownloadsDownloadFunction(), base::StringPrintf( | 1762 new DownloadsDownloadFunction(), base::StringPrintf( |
| 1763 "[{\"url\": \"%s\"," | 1763 "[{\"url\": \"%s\"," |
| 1764 " \"filename\": \"headers-succeed.txt\"," | 1764 " \"filename\": \"headers-succeed.txt\"," |
| 1765 " \"headers\": [" | 1765 " \"headers\": [" |
| 1766 " {\"name\": \"Foo\", \"value\": \"bar\"}," | 1766 " {\"name\": \"Foo\", \"value\": \"bar\"}," |
| 1767 " {\"name\": \"Qx\", \"value\":\"yo\"}]}]", | 1767 " {\"name\": \"Qx\", \"value\":\"yo\"}]}]", |
| 1768 download_url.c_str()))); | 1768 download_url.c_str()))); |
| 1769 ASSERT_TRUE(result.get()); | 1769 ASSERT_TRUE(result.get()); |
| 1770 int result_id = -1; | 1770 int result_id = -1; |
| 1771 ASSERT_TRUE(result->GetAsInteger(&result_id)); | 1771 ASSERT_TRUE(result->GetAsInteger(&result_id)); |
| 1772 DownloadItem* item = GetCurrentManager()->GetActiveDownloadItem(result_id); | 1772 DownloadItem* item = GetCurrentManager()->GetDownload(result_id); |
| 1773 if (!item) item = GetCurrentManager()->GetDownloadItem(result_id); | 1773 if (!item) item = GetCurrentManager()->GetDownload(result_id); |
| 1774 ASSERT_TRUE(item); | 1774 ASSERT_TRUE(item); |
| 1775 ScopedCancellingItem canceller(item); | 1775 ScopedCancellingItem canceller(item); |
| 1776 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 1776 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
| 1777 | 1777 |
| 1778 ASSERT_TRUE(WaitFor(events::kOnDownloadCreated, | 1778 ASSERT_TRUE(WaitFor(events::kOnDownloadCreated, |
| 1779 base::StringPrintf("[{\"danger\": \"safe\"," | 1779 base::StringPrintf("[{\"danger\": \"safe\"," |
| 1780 " \"incognito\": false," | 1780 " \"incognito\": false," |
| 1781 " \"mime\": \"application/octet-stream\"," | 1781 " \"mime\": \"application/octet-stream\"," |
| 1782 " \"paused\": false," | 1782 " \"paused\": false," |
| 1783 " \"url\": \"%s\"}]", | 1783 " \"url\": \"%s\"}]", |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 1810 GoOnTheRecord(); | 1810 GoOnTheRecord(); |
| 1811 | 1811 |
| 1812 scoped_ptr<base::Value> result(RunFunctionAndReturnResult( | 1812 scoped_ptr<base::Value> result(RunFunctionAndReturnResult( |
| 1813 new DownloadsDownloadFunction(), base::StringPrintf( | 1813 new DownloadsDownloadFunction(), base::StringPrintf( |
| 1814 "[{\"url\": \"%s\"," | 1814 "[{\"url\": \"%s\"," |
| 1815 " \"filename\": \"headers-fail.txt\"}]", | 1815 " \"filename\": \"headers-fail.txt\"}]", |
| 1816 download_url.c_str()))); | 1816 download_url.c_str()))); |
| 1817 ASSERT_TRUE(result.get()); | 1817 ASSERT_TRUE(result.get()); |
| 1818 int result_id = -1; | 1818 int result_id = -1; |
| 1819 ASSERT_TRUE(result->GetAsInteger(&result_id)); | 1819 ASSERT_TRUE(result->GetAsInteger(&result_id)); |
| 1820 DownloadItem* item = GetCurrentManager()->GetActiveDownloadItem(result_id); | 1820 DownloadItem* item = GetCurrentManager()->GetDownload(result_id); |
| 1821 if (!item) item = GetCurrentManager()->GetDownloadItem(result_id); | 1821 if (!item) item = GetCurrentManager()->GetDownload(result_id); |
| 1822 ASSERT_TRUE(item); | 1822 ASSERT_TRUE(item); |
| 1823 ScopedCancellingItem canceller(item); | 1823 ScopedCancellingItem canceller(item); |
| 1824 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 1824 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
| 1825 | 1825 |
| 1826 ASSERT_TRUE(WaitForInterruption(item, 33, base::StringPrintf( | 1826 ASSERT_TRUE(WaitForInterruption(item, 33, base::StringPrintf( |
| 1827 "[{\"danger\": \"safe\"," | 1827 "[{\"danger\": \"safe\"," |
| 1828 " \"incognito\": false," | 1828 " \"incognito\": false," |
| 1829 " \"bytesReceived\": 0," | 1829 " \"bytesReceived\": 0," |
| 1830 " \"mime\": \"\"," | 1830 " \"mime\": \"\"," |
| 1831 " \"paused\": false," | 1831 " \"paused\": false," |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 1848 new DownloadsDownloadFunction(), base::StringPrintf( | 1848 new DownloadsDownloadFunction(), base::StringPrintf( |
| 1849 "[{\"url\": \"%s\"," | 1849 "[{\"url\": \"%s\"," |
| 1850 " \"filename\": \"auth-basic-succeed.txt\"," | 1850 " \"filename\": \"auth-basic-succeed.txt\"," |
| 1851 " \"headers\": [{" | 1851 " \"headers\": [{" |
| 1852 " \"name\": \"Authorization\"," | 1852 " \"name\": \"Authorization\"," |
| 1853 " \"value\": \"Basic %s\"}]}]", | 1853 " \"value\": \"Basic %s\"}]}]", |
| 1854 download_url.c_str(), kAuthorization))); | 1854 download_url.c_str(), kAuthorization))); |
| 1855 ASSERT_TRUE(result.get()); | 1855 ASSERT_TRUE(result.get()); |
| 1856 int result_id = -1; | 1856 int result_id = -1; |
| 1857 ASSERT_TRUE(result->GetAsInteger(&result_id)); | 1857 ASSERT_TRUE(result->GetAsInteger(&result_id)); |
| 1858 DownloadItem* item = GetCurrentManager()->GetActiveDownloadItem(result_id); | 1858 DownloadItem* item = GetCurrentManager()->GetDownload(result_id); |
| 1859 if (!item) item = GetCurrentManager()->GetDownloadItem(result_id); | 1859 if (!item) item = GetCurrentManager()->GetDownload(result_id); |
| 1860 ASSERT_TRUE(item); | 1860 ASSERT_TRUE(item); |
| 1861 ScopedCancellingItem canceller(item); | 1861 ScopedCancellingItem canceller(item); |
| 1862 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 1862 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
| 1863 | 1863 |
| 1864 ASSERT_TRUE(WaitFor(events::kOnDownloadCreated, | 1864 ASSERT_TRUE(WaitFor(events::kOnDownloadCreated, |
| 1865 base::StringPrintf("[{\"danger\": \"safe\"," | 1865 base::StringPrintf("[{\"danger\": \"safe\"," |
| 1866 " \"incognito\": false," | 1866 " \"incognito\": false," |
| 1867 " \"mime\": \"text/html\"," | 1867 " \"mime\": \"text/html\"," |
| 1868 " \"paused\": false," | 1868 " \"paused\": false," |
| 1869 " \"url\": \"%s\"}]", download_url.c_str()))); | 1869 " \"url\": \"%s\"}]", download_url.c_str()))); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 1887 scoped_ptr<base::Value> result(RunFunctionAndReturnResult( | 1887 scoped_ptr<base::Value> result(RunFunctionAndReturnResult( |
| 1888 new DownloadsDownloadFunction(), base::StringPrintf( | 1888 new DownloadsDownloadFunction(), base::StringPrintf( |
| 1889 "[{\"url\": \"%s\"," | 1889 "[{\"url\": \"%s\"," |
| 1890 " \"filename\": \"post-succeed.txt\"," | 1890 " \"filename\": \"post-succeed.txt\"," |
| 1891 " \"method\": \"POST\"," | 1891 " \"method\": \"POST\"," |
| 1892 " \"body\": \"BODY\"}]", | 1892 " \"body\": \"BODY\"}]", |
| 1893 download_url.c_str()))); | 1893 download_url.c_str()))); |
| 1894 ASSERT_TRUE(result.get()); | 1894 ASSERT_TRUE(result.get()); |
| 1895 int result_id = -1; | 1895 int result_id = -1; |
| 1896 ASSERT_TRUE(result->GetAsInteger(&result_id)); | 1896 ASSERT_TRUE(result->GetAsInteger(&result_id)); |
| 1897 DownloadItem* item = GetCurrentManager()->GetActiveDownloadItem(result_id); | 1897 DownloadItem* item = GetCurrentManager()->GetDownload(result_id); |
| 1898 if (!item) item = GetCurrentManager()->GetDownloadItem(result_id); | 1898 if (!item) item = GetCurrentManager()->GetDownload(result_id); |
| 1899 ASSERT_TRUE(item); | 1899 ASSERT_TRUE(item); |
| 1900 ScopedCancellingItem canceller(item); | 1900 ScopedCancellingItem canceller(item); |
| 1901 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 1901 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
| 1902 | 1902 |
| 1903 ASSERT_TRUE(WaitFor(events::kOnDownloadCreated, | 1903 ASSERT_TRUE(WaitFor(events::kOnDownloadCreated, |
| 1904 base::StringPrintf("[{\"danger\": \"safe\"," | 1904 base::StringPrintf("[{\"danger\": \"safe\"," |
| 1905 " \"incognito\": false," | 1905 " \"incognito\": false," |
| 1906 " \"mime\": \"application/octet-stream\"," | 1906 " \"mime\": \"application/octet-stream\"," |
| 1907 " \"paused\": false," | 1907 " \"paused\": false," |
| 1908 " \"url\": \"%s\"}]", download_url.c_str()))); | 1908 " \"url\": \"%s\"}]", download_url.c_str()))); |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 1934 | 1934 |
| 1935 scoped_ptr<base::Value> result(RunFunctionAndReturnResult( | 1935 scoped_ptr<base::Value> result(RunFunctionAndReturnResult( |
| 1936 new DownloadsDownloadFunction(), base::StringPrintf( | 1936 new DownloadsDownloadFunction(), base::StringPrintf( |
| 1937 "[{\"url\": \"%s\"," | 1937 "[{\"url\": \"%s\"," |
| 1938 " \"body\": \"BODY\"," | 1938 " \"body\": \"BODY\"," |
| 1939 " \"filename\": \"post-get.txt\"}]", | 1939 " \"filename\": \"post-get.txt\"}]", |
| 1940 download_url.c_str()))); | 1940 download_url.c_str()))); |
| 1941 ASSERT_TRUE(result.get()); | 1941 ASSERT_TRUE(result.get()); |
| 1942 int result_id = -1; | 1942 int result_id = -1; |
| 1943 ASSERT_TRUE(result->GetAsInteger(&result_id)); | 1943 ASSERT_TRUE(result->GetAsInteger(&result_id)); |
| 1944 DownloadItem* item = GetCurrentManager()->GetActiveDownloadItem(result_id); | 1944 DownloadItem* item = GetCurrentManager()->GetDownload(result_id); |
| 1945 if (!item) item = GetCurrentManager()->GetDownloadItem(result_id); | 1945 if (!item) item = GetCurrentManager()->GetDownload(result_id); |
| 1946 ASSERT_TRUE(item); | 1946 ASSERT_TRUE(item); |
| 1947 ScopedCancellingItem canceller(item); | 1947 ScopedCancellingItem canceller(item); |
| 1948 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 1948 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
| 1949 | 1949 |
| 1950 ASSERT_TRUE(WaitForInterruption(item, 33, base::StringPrintf( | 1950 ASSERT_TRUE(WaitForInterruption(item, 33, base::StringPrintf( |
| 1951 "[{\"danger\": \"safe\"," | 1951 "[{\"danger\": \"safe\"," |
| 1952 " \"incognito\": false," | 1952 " \"incognito\": false," |
| 1953 " \"mime\": \"\"," | 1953 " \"mime\": \"\"," |
| 1954 " \"paused\": false," | 1954 " \"paused\": false," |
| 1955 " \"id\": %d," | 1955 " \"id\": %d," |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 1973 | 1973 |
| 1974 scoped_ptr<base::Value> result(RunFunctionAndReturnResult( | 1974 scoped_ptr<base::Value> result(RunFunctionAndReturnResult( |
| 1975 new DownloadsDownloadFunction(), base::StringPrintf( | 1975 new DownloadsDownloadFunction(), base::StringPrintf( |
| 1976 "[{\"url\": \"%s\"," | 1976 "[{\"url\": \"%s\"," |
| 1977 " \"method\": \"POST\"," | 1977 " \"method\": \"POST\"," |
| 1978 " \"filename\": \"post-nobody.txt\"}]", | 1978 " \"filename\": \"post-nobody.txt\"}]", |
| 1979 download_url.c_str()))); | 1979 download_url.c_str()))); |
| 1980 ASSERT_TRUE(result.get()); | 1980 ASSERT_TRUE(result.get()); |
| 1981 int result_id = -1; | 1981 int result_id = -1; |
| 1982 ASSERT_TRUE(result->GetAsInteger(&result_id)); | 1982 ASSERT_TRUE(result->GetAsInteger(&result_id)); |
| 1983 DownloadItem* item = GetCurrentManager()->GetActiveDownloadItem(result_id); | 1983 DownloadItem* item = GetCurrentManager()->GetDownload(result_id); |
| 1984 if (!item) item = GetCurrentManager()->GetDownloadItem(result_id); | 1984 if (!item) item = GetCurrentManager()->GetDownload(result_id); |
| 1985 ASSERT_TRUE(item); | 1985 ASSERT_TRUE(item); |
| 1986 ScopedCancellingItem canceller(item); | 1986 ScopedCancellingItem canceller(item); |
| 1987 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 1987 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
| 1988 | 1988 |
| 1989 ASSERT_TRUE(WaitForInterruption(item, 33, base::StringPrintf( | 1989 ASSERT_TRUE(WaitForInterruption(item, 33, base::StringPrintf( |
| 1990 "[{\"danger\": \"safe\"," | 1990 "[{\"danger\": \"safe\"," |
| 1991 " \"incognito\": false," | 1991 " \"incognito\": false," |
| 1992 " \"mime\": \"\"," | 1992 " \"mime\": \"\"," |
| 1993 " \"paused\": false," | 1993 " \"paused\": false," |
| 1994 " \"id\": %d," | 1994 " \"id\": %d," |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 2008 std::string download_url = test_server()->GetURL( | 2008 std::string download_url = test_server()->GetURL( |
| 2009 "download-known-size").spec(); | 2009 "download-known-size").spec(); |
| 2010 GoOnTheRecord(); | 2010 GoOnTheRecord(); |
| 2011 | 2011 |
| 2012 scoped_ptr<base::Value> result(RunFunctionAndReturnResult( | 2012 scoped_ptr<base::Value> result(RunFunctionAndReturnResult( |
| 2013 new DownloadsDownloadFunction(), base::StringPrintf( | 2013 new DownloadsDownloadFunction(), base::StringPrintf( |
| 2014 "[{\"url\": \"%s\"}]", download_url.c_str()))); | 2014 "[{\"url\": \"%s\"}]", download_url.c_str()))); |
| 2015 ASSERT_TRUE(result.get()); | 2015 ASSERT_TRUE(result.get()); |
| 2016 int result_id = -1; | 2016 int result_id = -1; |
| 2017 ASSERT_TRUE(result->GetAsInteger(&result_id)); | 2017 ASSERT_TRUE(result->GetAsInteger(&result_id)); |
| 2018 DownloadItem* item = GetCurrentManager()->GetActiveDownloadItem(result_id); | 2018 DownloadItem* item = GetCurrentManager()->GetDownload(result_id); |
| 2019 if (!item) item = GetCurrentManager()->GetDownloadItem(result_id); | 2019 if (!item) item = GetCurrentManager()->GetDownload(result_id); |
| 2020 ASSERT_TRUE(item); | 2020 ASSERT_TRUE(item); |
| 2021 ScopedCancellingItem canceller(item); | 2021 ScopedCancellingItem canceller(item); |
| 2022 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 2022 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
| 2023 | 2023 |
| 2024 ASSERT_TRUE(WaitFor(events::kOnDownloadCreated, | 2024 ASSERT_TRUE(WaitFor(events::kOnDownloadCreated, |
| 2025 base::StringPrintf("[{\"danger\": \"safe\"," | 2025 base::StringPrintf("[{\"danger\": \"safe\"," |
| 2026 " \"incognito\": false," | 2026 " \"incognito\": false," |
| 2027 " \"mime\": \"application/octet-stream\"," | 2027 " \"mime\": \"application/octet-stream\"," |
| 2028 " \"paused\": false," | 2028 " \"paused\": false," |
| 2029 " \"id\": %d," | 2029 " \"id\": %d," |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 2057 | 2057 |
| 2058 std::string download_url = "filesystem:" + GetExtensionURL() + | 2058 std::string download_url = "filesystem:" + GetExtensionURL() + |
| 2059 "temporary/on_record.txt"; | 2059 "temporary/on_record.txt"; |
| 2060 scoped_ptr<base::Value> result(RunFunctionAndReturnResult( | 2060 scoped_ptr<base::Value> result(RunFunctionAndReturnResult( |
| 2061 new DownloadsDownloadFunction(), base::StringPrintf( | 2061 new DownloadsDownloadFunction(), base::StringPrintf( |
| 2062 "[{\"url\": \"%s\"}]", download_url.c_str()))); | 2062 "[{\"url\": \"%s\"}]", download_url.c_str()))); |
| 2063 ASSERT_TRUE(result.get()); | 2063 ASSERT_TRUE(result.get()); |
| 2064 int result_id = -1; | 2064 int result_id = -1; |
| 2065 ASSERT_TRUE(result->GetAsInteger(&result_id)); | 2065 ASSERT_TRUE(result->GetAsInteger(&result_id)); |
| 2066 | 2066 |
| 2067 DownloadItem* item = GetCurrentManager()->GetActiveDownloadItem(result_id); | 2067 DownloadItem* item = GetCurrentManager()->GetDownload(result_id); |
| 2068 if (!item) item = GetCurrentManager()->GetDownloadItem(result_id); | 2068 if (!item) item = GetCurrentManager()->GetDownload(result_id); |
| 2069 ASSERT_TRUE(item); | 2069 ASSERT_TRUE(item); |
| 2070 ScopedCancellingItem canceller(item); | 2070 ScopedCancellingItem canceller(item); |
| 2071 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); | 2071 ASSERT_EQ(download_url, item->GetOriginalUrl().spec()); |
| 2072 | 2072 |
| 2073 ASSERT_TRUE(WaitFor(events::kOnDownloadCreated, | 2073 ASSERT_TRUE(WaitFor(events::kOnDownloadCreated, |
| 2074 base::StringPrintf("[{\"danger\": \"safe\"," | 2074 base::StringPrintf("[{\"danger\": \"safe\"," |
| 2075 " \"incognito\": false," | 2075 " \"incognito\": false," |
| 2076 " \"mime\": \"text/plain\"," | 2076 " \"mime\": \"text/plain\"," |
| 2077 " \"paused\": false," | 2077 " \"paused\": false," |
| 2078 " \"url\": \"%s\"}]", | 2078 " \"url\": \"%s\"}]", |
| 2079 download_url.c_str()))); | 2079 download_url.c_str()))); |
| 2080 ASSERT_TRUE(WaitFor(events::kOnDownloadChanged, | 2080 ASSERT_TRUE(WaitFor(events::kOnDownloadChanged, |
| 2081 base::StringPrintf("[{\"id\": %d," | 2081 base::StringPrintf("[{\"id\": %d," |
| 2082 " \"filename\": {" | 2082 " \"filename\": {" |
| 2083 " \"previous\": \"%s\"," | 2083 " \"previous\": \"%s\"," |
| 2084 " \"current\": \"%s\"}," | 2084 " \"current\": \"%s\"}," |
| 2085 " \"state\": {" | 2085 " \"state\": {" |
| 2086 " \"previous\": \"in_progress\"," | 2086 " \"previous\": \"in_progress\"," |
| 2087 " \"current\": \"complete\"}}]", | 2087 " \"current\": \"complete\"}}]", |
| 2088 result_id, | 2088 result_id, |
| 2089 GetFilename("on_record.txt.crdownload").c_str(), | 2089 GetFilename("on_record.txt.crdownload").c_str(), |
| 2090 GetFilename("on_record.txt").c_str()))); | 2090 GetFilename("on_record.txt").c_str()))); |
| 2091 std::string disk_data; | 2091 std::string disk_data; |
| 2092 EXPECT_TRUE(file_util::ReadFileToString(item->GetFullPath(), &disk_data)); | 2092 EXPECT_TRUE(file_util::ReadFileToString(item->GetFullPath(), &disk_data)); |
| 2093 EXPECT_STREQ(kPayloadData, disk_data.c_str()); | 2093 EXPECT_STREQ(kPayloadData, disk_data.c_str()); |
| 2094 } | 2094 } |
| OLD | NEW |