Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(523)

Side by Side Diff: chrome/browser/extensions/api/downloads/downloads_api_browsertest.cc

Issue 2592793002: Revert of Change how the quota system computes the total poolsize for temporary storage (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 // Disable everything on windows only. http://crbug.com/306144 5 // Disable everything on windows only. http://crbug.com/306144
6 #ifndef OS_WIN 6 #ifndef OS_WIN
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <algorithm> 11 #include <algorithm>
12 12
13 #include "base/files/file_util.h" 13 #include "base/files/file_util.h"
14 #include "base/files/scoped_temp_dir.h" 14 #include "base/files/scoped_temp_dir.h"
15 #include "base/guid.h" 15 #include "base/guid.h"
16 #include "base/json/json_reader.h" 16 #include "base/json/json_reader.h"
17 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "base/memory/ptr_util.h" 18 #include "base/memory/ptr_util.h"
19 #include "base/message_loop/message_loop.h" 19 #include "base/message_loop/message_loop.h"
20 #include "base/run_loop.h"
21 #include "base/strings/stringprintf.h" 20 #include "base/strings/stringprintf.h"
21 #include "base/synchronization/waitable_event.h"
22 #include "build/build_config.h" 22 #include "build/build_config.h"
23 #include "chrome/browser/download/download_file_icon_extractor.h" 23 #include "chrome/browser/download/download_file_icon_extractor.h"
24 #include "chrome/browser/download/download_service.h" 24 #include "chrome/browser/download/download_service.h"
25 #include "chrome/browser/download/download_service_factory.h" 25 #include "chrome/browser/download/download_service_factory.h"
26 #include "chrome/browser/download/download_test_file_activity_observer.h" 26 #include "chrome/browser/download/download_test_file_activity_observer.h"
27 #include "chrome/browser/extensions/api/downloads/downloads_api.h" 27 #include "chrome/browser/extensions/api/downloads/downloads_api.h"
28 #include "chrome/browser/extensions/browser_action_test_util.h" 28 #include "chrome/browser/extensions/browser_action_test_util.h"
29 #include "chrome/browser/extensions/extension_apitest.h" 29 #include "chrome/browser/extensions/extension_apitest.h"
30 #include "chrome/browser/extensions/extension_function_test_utils.h" 30 #include "chrome/browser/extensions/extension_function_test_utils.h"
31 #include "chrome/browser/net/url_request_mock_util.h" 31 #include "chrome/browser/net/url_request_mock_util.h"
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 const char* data, 696 const char* data,
697 int length) { 697 int length) {
698 // Create a temp file. 698 // Create a temp file.
699 base::FilePath temp_file; 699 base::FilePath temp_file;
700 if (!base::CreateTemporaryFile(&temp_file) || 700 if (!base::CreateTemporaryFile(&temp_file) ||
701 base::WriteFile(temp_file, data, length) != length) { 701 base::WriteFile(temp_file, data, length) != length) {
702 return false; 702 return false;
703 } 703 }
704 // Invoke the fileapi to copy it into the sandboxed filesystem. 704 // Invoke the fileapi to copy it into the sandboxed filesystem.
705 bool result = false; 705 bool result = false;
706 base::RunLoop run_loop; 706 base::WaitableEvent done_event(
707 base::WaitableEvent::ResetPolicy::MANUAL,
708 base::WaitableEvent::InitialState::NOT_SIGNALED);
707 BrowserThread::PostTask( 709 BrowserThread::PostTask(
708 BrowserThread::IO, FROM_HERE, 710 BrowserThread::IO, FROM_HERE,
709 base::Bind(&CreateFileForTestingOnIOThread, base::Unretained(context), 711 base::Bind(&CreateFileForTestingOnIOThread,
710 path, temp_file, base::Unretained(&result), 712 base::Unretained(context),
711 run_loop.QuitClosure())); 713 path, temp_file,
714 base::Unretained(&result),
715 base::Unretained(&done_event)));
712 // Wait for that to finish. 716 // Wait for that to finish.
713 run_loop.Run(); 717 done_event.Wait();
714 base::DeleteFile(temp_file, false); 718 base::DeleteFile(temp_file, false);
715 return result; 719 return result;
716 } 720 }
717 721
718 private: 722 private:
719 static void CopyInCompletion(bool* result, 723 static void CopyInCompletion(bool* result,
720 const base::Closure& quit_closure, 724 base::WaitableEvent* done_event,
721 base::File::Error error) { 725 base::File::Error error) {
722 DCHECK_CURRENTLY_ON(BrowserThread::IO); 726 DCHECK_CURRENTLY_ON(BrowserThread::IO);
723 *result = error == base::File::FILE_OK; 727 *result = error == base::File::FILE_OK;
724 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, quit_closure); 728 done_event->Signal();
725 } 729 }
726 730
727 static void CreateFileForTestingOnIOThread( 731 static void CreateFileForTestingOnIOThread(
728 storage::FileSystemContext* context, 732 storage::FileSystemContext* context,
729 const storage::FileSystemURL& path, 733 const storage::FileSystemURL& path,
730 const base::FilePath& temp_file, 734 const base::FilePath& temp_file,
731 bool* result, 735 bool* result,
732 const base::Closure& quit_closure) { 736 base::WaitableEvent* done_event) {
733 DCHECK_CURRENTLY_ON(BrowserThread::IO); 737 DCHECK_CURRENTLY_ON(BrowserThread::IO);
734 context->operation_runner()->CopyInForeignFile( 738 context->operation_runner()->CopyInForeignFile(
735 temp_file, path, 739 temp_file, path,
736 base::Bind(&CopyInCompletion, base::Unretained(result), quit_closure)); 740 base::Bind(&CopyInCompletion,
741 base::Unretained(result),
742 base::Unretained(done_event)));
737 } 743 }
738 }; 744 };
739 745
740 // TODO(benjhayden) Merge this with the other TestObservers. 746 // TODO(benjhayden) Merge this with the other TestObservers.
741 class JustInProgressDownloadObserver 747 class JustInProgressDownloadObserver
742 : public content::DownloadTestObserverInProgress { 748 : public content::DownloadTestObserverInProgress {
743 public: 749 public:
744 JustInProgressDownloadObserver( 750 JustInProgressDownloadObserver(
745 DownloadManager* download_manager, size_t wait_count) 751 DownloadManager* download_manager, size_t wait_count)
746 : content::DownloadTestObserverInProgress(download_manager, wait_count) { 752 : content::DownloadTestObserverInProgress(download_manager, wait_count) {
(...skipping 3550 matching lines...) Expand 10 before | Expand all | Expand 10 after
4297 EXPECT_EQ(downloads::FILENAME_CONFLICT_ACTION_PROMPT, conflict_action); 4303 EXPECT_EQ(downloads::FILENAME_CONFLICT_ACTION_PROMPT, conflict_action);
4298 EXPECT_FALSE(warnings.empty()); 4304 EXPECT_FALSE(warnings.empty());
4299 EXPECT_EQ(Warning::kDownloadFilenameConflict, 4305 EXPECT_EQ(Warning::kDownloadFilenameConflict,
4300 warnings.begin()->warning_type()); 4306 warnings.begin()->warning_type());
4301 EXPECT_EQ("incumbent", warnings.begin()->extension_id()); 4307 EXPECT_EQ("incumbent", warnings.begin()->extension_id());
4302 } 4308 }
4303 4309
4304 } // namespace extensions 4310 } // namespace extensions
4305 4311
4306 #endif // http://crbug.com/306144 4312 #endif // http://crbug.com/306144
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698