| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <utility> | 5 #include <utility> |
| 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/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 static scoped_ptr<UpdateChecker> Create( | 219 static scoped_ptr<UpdateChecker> Create( |
| 220 const scoped_refptr<Configurator>& config) { | 220 const scoped_refptr<Configurator>& config) { |
| 221 return scoped_ptr<UpdateChecker>(new FakeUpdateChecker()); | 221 return scoped_ptr<UpdateChecker>(new FakeUpdateChecker()); |
| 222 } | 222 } |
| 223 | 223 |
| 224 bool CheckForUpdates( | 224 bool CheckForUpdates( |
| 225 const std::vector<CrxUpdateItem*>& items_to_check, | 225 const std::vector<CrxUpdateItem*>& items_to_check, |
| 226 const std::string& additional_attributes, | 226 const std::string& additional_attributes, |
| 227 const UpdateCheckCallback& update_check_callback) override { | 227 const UpdateCheckCallback& update_check_callback) override { |
| 228 base::ThreadTaskRunnerHandle::Get()->PostTask( | 228 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 229 FROM_HERE, base::Bind(update_check_callback, GURL(), 0, "", | 229 FROM_HERE, |
| 230 UpdateResponse::Results())); | 230 base::Bind(update_check_callback, 0, UpdateResponse::Results())); |
| 231 return true; | 231 return true; |
| 232 } | 232 } |
| 233 }; | 233 }; |
| 234 | 234 |
| 235 class FakeCrxDownloader : public CrxDownloader { | 235 class FakeCrxDownloader : public CrxDownloader { |
| 236 public: | 236 public: |
| 237 static scoped_ptr<CrxDownloader> Create( | 237 static scoped_ptr<CrxDownloader> Create( |
| 238 bool is_background_download, | 238 bool is_background_download, |
| 239 net::URLRequestContextGetter* context_getter, | 239 net::URLRequestContextGetter* context_getter, |
| 240 const scoped_refptr<base::SequencedTaskRunner>& task_runner) { | 240 const scoped_refptr<base::SequencedTaskRunner>& task_runner) { |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 result.extension_id = "jebgalgnebhfojomionfpkfelancnnkf"; | 361 result.extension_id = "jebgalgnebhfojomionfpkfelancnnkf"; |
| 362 result.crx_urls.push_back(GURL("http://localhost/download/")); | 362 result.crx_urls.push_back(GURL("http://localhost/download/")); |
| 363 result.manifest.version = "1.0"; | 363 result.manifest.version = "1.0"; |
| 364 result.manifest.browser_min_version = "11.0.1.0"; | 364 result.manifest.browser_min_version = "11.0.1.0"; |
| 365 result.manifest.packages.push_back(package); | 365 result.manifest.packages.push_back(package); |
| 366 | 366 |
| 367 UpdateResponse::Results results; | 367 UpdateResponse::Results results; |
| 368 results.list.push_back(result); | 368 results.list.push_back(result); |
| 369 | 369 |
| 370 base::ThreadTaskRunnerHandle::Get()->PostTask( | 370 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 371 FROM_HERE, base::Bind(update_check_callback, GURL(), 0, "", results)); | 371 FROM_HERE, base::Bind(update_check_callback, 0, results)); |
| 372 return true; | 372 return true; |
| 373 } | 373 } |
| 374 }; | 374 }; |
| 375 | 375 |
| 376 class FakeCrxDownloader : public CrxDownloader { | 376 class FakeCrxDownloader : public CrxDownloader { |
| 377 public: | 377 public: |
| 378 static scoped_ptr<CrxDownloader> Create( | 378 static scoped_ptr<CrxDownloader> Create( |
| 379 bool is_background_download, | 379 bool is_background_download, |
| 380 net::URLRequestContextGetter* context_getter, | 380 net::URLRequestContextGetter* context_getter, |
| 381 const scoped_refptr<base::SequencedTaskRunner>& task_runner) { | 381 const scoped_refptr<base::SequencedTaskRunner>& task_runner) { |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 result2.crx_urls.push_back(GURL("http://localhost/download/")); | 573 result2.crx_urls.push_back(GURL("http://localhost/download/")); |
| 574 result2.manifest.version = "1.0"; | 574 result2.manifest.version = "1.0"; |
| 575 result2.manifest.browser_min_version = "11.0.1.0"; | 575 result2.manifest.browser_min_version = "11.0.1.0"; |
| 576 result2.manifest.packages.push_back(package2); | 576 result2.manifest.packages.push_back(package2); |
| 577 | 577 |
| 578 UpdateResponse::Results results; | 578 UpdateResponse::Results results; |
| 579 results.list.push_back(result1); | 579 results.list.push_back(result1); |
| 580 results.list.push_back(result2); | 580 results.list.push_back(result2); |
| 581 | 581 |
| 582 base::ThreadTaskRunnerHandle::Get()->PostTask( | 582 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 583 FROM_HERE, base::Bind(update_check_callback, GURL(), 0, "", results)); | 583 FROM_HERE, base::Bind(update_check_callback, 0, results)); |
| 584 return true; | 584 return true; |
| 585 } | 585 } |
| 586 }; | 586 }; |
| 587 | 587 |
| 588 class FakeCrxDownloader : public CrxDownloader { | 588 class FakeCrxDownloader : public CrxDownloader { |
| 589 public: | 589 public: |
| 590 static scoped_ptr<CrxDownloader> Create( | 590 static scoped_ptr<CrxDownloader> Create( |
| 591 bool is_background_download, | 591 bool is_background_download, |
| 592 net::URLRequestContextGetter* context_getter, | 592 net::URLRequestContextGetter* context_getter, |
| 593 const scoped_refptr<base::SequencedTaskRunner>& task_runner) { | 593 const scoped_refptr<base::SequencedTaskRunner>& task_runner) { |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 820 result2.crx_urls.push_back(GURL("http://localhost/download/")); | 820 result2.crx_urls.push_back(GURL("http://localhost/download/")); |
| 821 result2.manifest.version = "1.0"; | 821 result2.manifest.version = "1.0"; |
| 822 result2.manifest.browser_min_version = "11.0.1.0"; | 822 result2.manifest.browser_min_version = "11.0.1.0"; |
| 823 result2.manifest.packages.push_back(package2); | 823 result2.manifest.packages.push_back(package2); |
| 824 | 824 |
| 825 UpdateResponse::Results results; | 825 UpdateResponse::Results results; |
| 826 results.list.push_back(result1); | 826 results.list.push_back(result1); |
| 827 results.list.push_back(result2); | 827 results.list.push_back(result2); |
| 828 | 828 |
| 829 base::ThreadTaskRunnerHandle::Get()->PostTask( | 829 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 830 FROM_HERE, base::Bind(update_check_callback, GURL(), 0, "", results)); | 830 FROM_HERE, base::Bind(update_check_callback, 0, results)); |
| 831 return true; | 831 return true; |
| 832 } | 832 } |
| 833 }; | 833 }; |
| 834 | 834 |
| 835 class FakeCrxDownloader : public CrxDownloader { | 835 class FakeCrxDownloader : public CrxDownloader { |
| 836 public: | 836 public: |
| 837 static scoped_ptr<CrxDownloader> Create( | 837 static scoped_ptr<CrxDownloader> Create( |
| 838 bool is_background_download, | 838 bool is_background_download, |
| 839 net::URLRequestContextGetter* context_getter, | 839 net::URLRequestContextGetter* context_getter, |
| 840 const scoped_refptr<base::SequencedTaskRunner>& task_runner) { | 840 const scoped_refptr<base::SequencedTaskRunner>& task_runner) { |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1092 result.crx_diffurls.push_back(GURL("http://localhost/download/")); | 1092 result.crx_diffurls.push_back(GURL("http://localhost/download/")); |
| 1093 result.manifest.version = "2.0"; | 1093 result.manifest.version = "2.0"; |
| 1094 result.manifest.browser_min_version = "11.0.1.0"; | 1094 result.manifest.browser_min_version = "11.0.1.0"; |
| 1095 result.manifest.packages.push_back(package); | 1095 result.manifest.packages.push_back(package); |
| 1096 results.list.push_back(result); | 1096 results.list.push_back(result); |
| 1097 } else { | 1097 } else { |
| 1098 NOTREACHED(); | 1098 NOTREACHED(); |
| 1099 } | 1099 } |
| 1100 | 1100 |
| 1101 base::ThreadTaskRunnerHandle::Get()->PostTask( | 1101 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 1102 FROM_HERE, base::Bind(update_check_callback, GURL(), 0, "", results)); | 1102 FROM_HERE, base::Bind(update_check_callback, 0, results)); |
| 1103 return true; | 1103 return true; |
| 1104 } | 1104 } |
| 1105 }; | 1105 }; |
| 1106 | 1106 |
| 1107 class FakeCrxDownloader : public CrxDownloader { | 1107 class FakeCrxDownloader : public CrxDownloader { |
| 1108 public: | 1108 public: |
| 1109 static scoped_ptr<CrxDownloader> Create( | 1109 static scoped_ptr<CrxDownloader> Create( |
| 1110 bool is_background_download, | 1110 bool is_background_download, |
| 1111 net::URLRequestContextGetter* context_getter, | 1111 net::URLRequestContextGetter* context_getter, |
| 1112 const scoped_refptr<base::SequencedTaskRunner>& task_runner) { | 1112 const scoped_refptr<base::SequencedTaskRunner>& task_runner) { |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1333 result.extension_id = "jebgalgnebhfojomionfpkfelancnnkf"; | 1333 result.extension_id = "jebgalgnebhfojomionfpkfelancnnkf"; |
| 1334 result.crx_urls.push_back(GURL("http://localhost/download/")); | 1334 result.crx_urls.push_back(GURL("http://localhost/download/")); |
| 1335 result.manifest.version = "1.0"; | 1335 result.manifest.version = "1.0"; |
| 1336 result.manifest.browser_min_version = "11.0.1.0"; | 1336 result.manifest.browser_min_version = "11.0.1.0"; |
| 1337 result.manifest.packages.push_back(package); | 1337 result.manifest.packages.push_back(package); |
| 1338 | 1338 |
| 1339 UpdateResponse::Results results; | 1339 UpdateResponse::Results results; |
| 1340 results.list.push_back(result); | 1340 results.list.push_back(result); |
| 1341 | 1341 |
| 1342 base::ThreadTaskRunnerHandle::Get()->PostTask( | 1342 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 1343 FROM_HERE, base::Bind(update_check_callback, GURL(), 0, "", results)); | 1343 FROM_HERE, base::Bind(update_check_callback, 0, results)); |
| 1344 return true; | 1344 return true; |
| 1345 } | 1345 } |
| 1346 }; | 1346 }; |
| 1347 | 1347 |
| 1348 class FakeCrxDownloader : public CrxDownloader { | 1348 class FakeCrxDownloader : public CrxDownloader { |
| 1349 public: | 1349 public: |
| 1350 static scoped_ptr<CrxDownloader> Create( | 1350 static scoped_ptr<CrxDownloader> Create( |
| 1351 bool is_background_download, | 1351 bool is_background_download, |
| 1352 net::URLRequestContextGetter* context_getter, | 1352 net::URLRequestContextGetter* context_getter, |
| 1353 const scoped_refptr<base::SequencedTaskRunner>& task_runner) { | 1353 const scoped_refptr<base::SequencedTaskRunner>& task_runner) { |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1566 result.crx_diffurls.push_back(GURL("http://localhost/download/")); | 1566 result.crx_diffurls.push_back(GURL("http://localhost/download/")); |
| 1567 result.manifest.version = "2.0"; | 1567 result.manifest.version = "2.0"; |
| 1568 result.manifest.browser_min_version = "11.0.1.0"; | 1568 result.manifest.browser_min_version = "11.0.1.0"; |
| 1569 result.manifest.packages.push_back(package); | 1569 result.manifest.packages.push_back(package); |
| 1570 results.list.push_back(result); | 1570 results.list.push_back(result); |
| 1571 } else { | 1571 } else { |
| 1572 NOTREACHED(); | 1572 NOTREACHED(); |
| 1573 } | 1573 } |
| 1574 | 1574 |
| 1575 base::ThreadTaskRunnerHandle::Get()->PostTask( | 1575 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 1576 FROM_HERE, base::Bind(update_check_callback, GURL(), 0, "", results)); | 1576 FROM_HERE, base::Bind(update_check_callback, 0, results)); |
| 1577 return true; | 1577 return true; |
| 1578 } | 1578 } |
| 1579 }; | 1579 }; |
| 1580 | 1580 |
| 1581 class FakeCrxDownloader : public CrxDownloader { | 1581 class FakeCrxDownloader : public CrxDownloader { |
| 1582 public: | 1582 public: |
| 1583 static scoped_ptr<CrxDownloader> Create( | 1583 static scoped_ptr<CrxDownloader> Create( |
| 1584 bool is_background_download, | 1584 bool is_background_download, |
| 1585 net::URLRequestContextGetter* context_getter, | 1585 net::URLRequestContextGetter* context_getter, |
| 1586 const scoped_refptr<base::SequencedTaskRunner>& task_runner) { | 1586 const scoped_refptr<base::SequencedTaskRunner>& task_runner) { |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1770 static scoped_ptr<UpdateChecker> Create( | 1770 static scoped_ptr<UpdateChecker> Create( |
| 1771 const scoped_refptr<Configurator>& config) { | 1771 const scoped_refptr<Configurator>& config) { |
| 1772 return scoped_ptr<UpdateChecker>(new FakeUpdateChecker()); | 1772 return scoped_ptr<UpdateChecker>(new FakeUpdateChecker()); |
| 1773 } | 1773 } |
| 1774 | 1774 |
| 1775 bool CheckForUpdates( | 1775 bool CheckForUpdates( |
| 1776 const std::vector<CrxUpdateItem*>& items_to_check, | 1776 const std::vector<CrxUpdateItem*>& items_to_check, |
| 1777 const std::string& additional_attributes, | 1777 const std::string& additional_attributes, |
| 1778 const UpdateCheckCallback& update_check_callback) override { | 1778 const UpdateCheckCallback& update_check_callback) override { |
| 1779 base::ThreadTaskRunnerHandle::Get()->PostTask( | 1779 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 1780 FROM_HERE, base::Bind(update_check_callback, GURL(), 0, "", | 1780 FROM_HERE, |
| 1781 UpdateResponse::Results())); | 1781 base::Bind(update_check_callback, 0, UpdateResponse::Results())); |
| 1782 return true; | 1782 return true; |
| 1783 } | 1783 } |
| 1784 }; | 1784 }; |
| 1785 | 1785 |
| 1786 class FakeCrxDownloader : public CrxDownloader { | 1786 class FakeCrxDownloader : public CrxDownloader { |
| 1787 public: | 1787 public: |
| 1788 static scoped_ptr<CrxDownloader> Create( | 1788 static scoped_ptr<CrxDownloader> Create( |
| 1789 bool is_background_download, | 1789 bool is_background_download, |
| 1790 net::URLRequestContextGetter* context_getter, | 1790 net::URLRequestContextGetter* context_getter, |
| 1791 const scoped_refptr<base::SequencedTaskRunner>& task_runner) { | 1791 const scoped_refptr<base::SequencedTaskRunner>& task_runner) { |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1904 result.extension_id = "jebgalgnebhfojomionfpkfelancnnkf"; | 1904 result.extension_id = "jebgalgnebhfojomionfpkfelancnnkf"; |
| 1905 result.crx_urls.push_back(GURL("http://localhost/download/")); | 1905 result.crx_urls.push_back(GURL("http://localhost/download/")); |
| 1906 result.manifest.version = "1.0"; | 1906 result.manifest.version = "1.0"; |
| 1907 result.manifest.browser_min_version = "11.0.1.0"; | 1907 result.manifest.browser_min_version = "11.0.1.0"; |
| 1908 result.manifest.packages.push_back(package); | 1908 result.manifest.packages.push_back(package); |
| 1909 | 1909 |
| 1910 UpdateResponse::Results results; | 1910 UpdateResponse::Results results; |
| 1911 results.list.push_back(result); | 1911 results.list.push_back(result); |
| 1912 | 1912 |
| 1913 base::ThreadTaskRunnerHandle::Get()->PostTask( | 1913 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 1914 FROM_HERE, base::Bind(update_check_callback, GURL(), 0, "", results)); | 1914 FROM_HERE, base::Bind(update_check_callback, 0, results)); |
| 1915 return true; | 1915 return true; |
| 1916 } | 1916 } |
| 1917 }; | 1917 }; |
| 1918 | 1918 |
| 1919 class FakeCrxDownloader : public CrxDownloader { | 1919 class FakeCrxDownloader : public CrxDownloader { |
| 1920 public: | 1920 public: |
| 1921 static scoped_ptr<CrxDownloader> Create( | 1921 static scoped_ptr<CrxDownloader> Create( |
| 1922 bool is_background_download, | 1922 bool is_background_download, |
| 1923 net::URLRequestContextGetter* context_getter, | 1923 net::URLRequestContextGetter* context_getter, |
| 1924 const scoped_refptr<base::SequencedTaskRunner>& task_runner) { | 1924 const scoped_refptr<base::SequencedTaskRunner>& task_runner) { |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2055 static scoped_ptr<UpdateChecker> Create( | 2055 static scoped_ptr<UpdateChecker> Create( |
| 2056 const scoped_refptr<Configurator>& config) { | 2056 const scoped_refptr<Configurator>& config) { |
| 2057 return scoped_ptr<UpdateChecker>(new FakeUpdateChecker()); | 2057 return scoped_ptr<UpdateChecker>(new FakeUpdateChecker()); |
| 2058 } | 2058 } |
| 2059 | 2059 |
| 2060 bool CheckForUpdates( | 2060 bool CheckForUpdates( |
| 2061 const std::vector<CrxUpdateItem*>& items_to_check, | 2061 const std::vector<CrxUpdateItem*>& items_to_check, |
| 2062 const std::string& additional_attributes, | 2062 const std::string& additional_attributes, |
| 2063 const UpdateCheckCallback& update_check_callback) override { | 2063 const UpdateCheckCallback& update_check_callback) override { |
| 2064 base::ThreadTaskRunnerHandle::Get()->PostTask( | 2064 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 2065 FROM_HERE, base::Bind(update_check_callback, GURL(), 0, "", | 2065 FROM_HERE, |
| 2066 UpdateResponse::Results())); | 2066 base::Bind(update_check_callback, 0, UpdateResponse::Results())); |
| 2067 return true; | 2067 return true; |
| 2068 } | 2068 } |
| 2069 }; | 2069 }; |
| 2070 | 2070 |
| 2071 class FakeCrxDownloader : public CrxDownloader { | 2071 class FakeCrxDownloader : public CrxDownloader { |
| 2072 public: | 2072 public: |
| 2073 static scoped_ptr<CrxDownloader> Create( | 2073 static scoped_ptr<CrxDownloader> Create( |
| 2074 bool is_background_download, | 2074 bool is_background_download, |
| 2075 net::URLRequestContextGetter* context_getter, | 2075 net::URLRequestContextGetter* context_getter, |
| 2076 const scoped_refptr<base::SequencedTaskRunner>& task_runner) { | 2076 const scoped_refptr<base::SequencedTaskRunner>& task_runner) { |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2237 scoped_ptr<PingManager> ping_manager(new FakePingManager(config())); | 2237 scoped_ptr<PingManager> ping_manager(new FakePingManager(config())); |
| 2238 scoped_refptr<UpdateClient> update_client(new UpdateClientImpl( | 2238 scoped_refptr<UpdateClient> update_client(new UpdateClientImpl( |
| 2239 config(), std::move(ping_manager), &FakeUpdateChecker::Create, | 2239 config(), std::move(ping_manager), &FakeUpdateChecker::Create, |
| 2240 &FakeCrxDownloader::Create)); | 2240 &FakeCrxDownloader::Create)); |
| 2241 | 2241 |
| 2242 update_client->SendUninstallPing("jebgalgnebhfojomionfpkfelancnnkf", | 2242 update_client->SendUninstallPing("jebgalgnebhfojomionfpkfelancnnkf", |
| 2243 base::Version("1.0"), 10); | 2243 base::Version("1.0"), 10); |
| 2244 } | 2244 } |
| 2245 | 2245 |
| 2246 } // namespace update_client | 2246 } // namespace update_client |
| OLD | NEW |