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

Side by Side Diff: chrome/browser/chromeos/extensions/file_manager/event_router.cc

Issue 1547093002: Switch to standard integer types in chrome/browser/chromeos/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 months 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/chromeos/extensions/file_manager/event_router.h" 5 #include "chrome/browser/chromeos/extensions/file_manager/event_router.h"
6 6
7 #include <stddef.h>
8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/command_line.h" 10 #include "base/command_line.h"
9 #include "base/files/file_util.h" 11 #include "base/files/file_util.h"
12 #include "base/macros.h"
10 #include "base/prefs/pref_change_registrar.h" 13 #include "base/prefs/pref_change_registrar.h"
11 #include "base/prefs/pref_service.h" 14 #include "base/prefs/pref_service.h"
12 #include "base/stl_util.h" 15 #include "base/stl_util.h"
13 #include "base/thread_task_runner_handle.h" 16 #include "base/thread_task_runner_handle.h"
14 #include "base/threading/sequenced_worker_pool.h" 17 #include "base/threading/sequenced_worker_pool.h"
15 #include "base/values.h" 18 #include "base/values.h"
16 #include "chrome/browser/app_mode/app_mode_utils.h" 19 #include "chrome/browser/app_mode/app_mode_utils.h"
17 #include "chrome/browser/chromeos/drive/drive_integration_service.h" 20 #include "chrome/browser/chromeos/drive/drive_integration_service.h"
18 #include "chrome/browser/chromeos/drive/file_system_util.h" 21 #include "chrome/browser/chromeos/drive/file_system_util.h"
19 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h" 22 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 using drive::DriveIntegrationServiceFactory; 57 using drive::DriveIntegrationServiceFactory;
55 using file_manager::util::EntryDefinition; 58 using file_manager::util::EntryDefinition;
56 using file_manager::util::FileDefinition; 59 using file_manager::util::FileDefinition;
57 60
58 namespace file_manager_private = extensions::api::file_manager_private; 61 namespace file_manager_private = extensions::api::file_manager_private;
59 62
60 namespace file_manager { 63 namespace file_manager {
61 namespace { 64 namespace {
62 65
63 // Frequency of sending onFileTransferUpdated. 66 // Frequency of sending onFileTransferUpdated.
64 const int64 kProgressEventFrequencyInMilliseconds = 1000; 67 const int64_t kProgressEventFrequencyInMilliseconds = 1000;
65 68
66 // Maximim size of detailed change info on directory change event. If the size 69 // Maximim size of detailed change info on directory change event. If the size
67 // exceeds the maximum size, the detailed info is omitted and the force refresh 70 // exceeds the maximum size, the detailed info is omitted and the force refresh
68 // is kicked. 71 // is kicked.
69 const size_t kDirectoryChangeEventMaxDetailInfoSize = 1000; 72 const size_t kDirectoryChangeEventMaxDetailInfoSize = 1000;
70 73
71 // This time(millisecond) is used for confirm following event exists. 74 // This time(millisecond) is used for confirm following event exists.
72 const int64 kFileTransferEventDelayTimeInMilliseconds = 300; 75 const int64_t kFileTransferEventDelayTimeInMilliseconds = 300;
73 76
74 // Checks if the Recovery Tool is running. This is a temporary solution. 77 // Checks if the Recovery Tool is running. This is a temporary solution.
75 // TODO(mtomasz): Replace with crbug.com/341902 solution. 78 // TODO(mtomasz): Replace with crbug.com/341902 solution.
76 bool IsRecoveryToolRunning(Profile* profile) { 79 bool IsRecoveryToolRunning(Profile* profile) {
77 extensions::ExtensionPrefs* extension_prefs = 80 extensions::ExtensionPrefs* extension_prefs =
78 extensions::ExtensionPrefs::Get(profile); 81 extensions::ExtensionPrefs::Get(profile);
79 if (!extension_prefs) 82 if (!extension_prefs)
80 return false; 83 return false;
81 84
82 const std::string kRecoveryToolIds[] = { 85 const std::string kRecoveryToolIds[] = {
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 return "InvalidModificationError"; 233 return "InvalidModificationError";
231 } 234 }
232 } 235 }
233 236
234 // Checks if we should send a progress event or not according to the 237 // Checks if we should send a progress event or not according to the
235 // |last_time| of sending an event. If |always| is true, the function always 238 // |last_time| of sending an event. If |always| is true, the function always
236 // returns true. If the function returns true, the function also updates 239 // returns true. If the function returns true, the function also updates
237 // |last_time|. 240 // |last_time|.
238 bool ShouldSendProgressEvent(bool always, base::Time* last_time) { 241 bool ShouldSendProgressEvent(bool always, base::Time* last_time) {
239 const base::Time now = base::Time::Now(); 242 const base::Time now = base::Time::Now();
240 const int64 delta = (now - *last_time).InMilliseconds(); 243 const int64_t delta = (now - *last_time).InMilliseconds();
241 // delta < 0 may rarely happen if system clock is synced and rewinded. 244 // delta < 0 may rarely happen if system clock is synced and rewinded.
242 // To be conservative, we don't skip in that case. 245 // To be conservative, we don't skip in that case.
243 if (!always && 0 <= delta && delta < kProgressEventFrequencyInMilliseconds) { 246 if (!always && 0 <= delta && delta < kProgressEventFrequencyInMilliseconds) {
244 return false; 247 return false;
245 } else { 248 } else {
246 *last_time = now; 249 *last_time = now;
247 return true; 250 return true;
248 } 251 }
249 } 252 }
250 253
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 extensions::events::FILE_MANAGER_PRIVATE_ON_COPY_PROGRESS, 566 extensions::events::FILE_MANAGER_PRIVATE_ON_COPY_PROGRESS,
564 file_manager_private::OnCopyProgress::kEventName, 567 file_manager_private::OnCopyProgress::kEventName,
565 file_manager_private::OnCopyProgress::Create(copy_id, status)); 568 file_manager_private::OnCopyProgress::Create(copy_id, status));
566 } 569 }
567 570
568 void EventRouter::OnCopyProgress( 571 void EventRouter::OnCopyProgress(
569 int copy_id, 572 int copy_id,
570 storage::FileSystemOperation::CopyProgressType type, 573 storage::FileSystemOperation::CopyProgressType type,
571 const GURL& source_url, 574 const GURL& source_url,
572 const GURL& destination_url, 575 const GURL& destination_url,
573 int64 size) { 576 int64_t size) {
574 DCHECK_CURRENTLY_ON(BrowserThread::UI); 577 DCHECK_CURRENTLY_ON(BrowserThread::UI);
575 578
576 file_manager_private::CopyProgressStatus status; 579 file_manager_private::CopyProgressStatus status;
577 status.type = CopyProgressTypeToCopyProgressStatusType(type); 580 status.type = CopyProgressTypeToCopyProgressStatusType(type);
578 status.source_url.reset(new std::string(source_url.spec())); 581 status.source_url.reset(new std::string(source_url.spec()));
579 if (type == storage::FileSystemOperation::END_COPY_ENTRY || 582 if (type == storage::FileSystemOperation::END_COPY_ENTRY ||
580 type == storage::FileSystemOperation::ERROR_COPY_ENTRY) 583 type == storage::FileSystemOperation::ERROR_COPY_ENTRY)
581 status.destination_url.reset(new std::string(destination_url.spec())); 584 status.destination_url.reset(new std::string(destination_url.spec()));
582 if (type == storage::FileSystemOperation::ERROR_COPY_ENTRY) 585 if (type == storage::FileSystemOperation::ERROR_COPY_ENTRY)
583 status.error.reset( 586 status.error.reset(
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
970 void EventRouter::SetDispatchDirectoryChangeEventImplForTesting( 973 void EventRouter::SetDispatchDirectoryChangeEventImplForTesting(
971 const DispatchDirectoryChangeEventImplCallback& callback) { 974 const DispatchDirectoryChangeEventImplCallback& callback) {
972 dispatch_directory_change_event_impl_ = callback; 975 dispatch_directory_change_event_impl_ = callback;
973 } 976 }
974 977
975 base::WeakPtr<EventRouter> EventRouter::GetWeakPtr() { 978 base::WeakPtr<EventRouter> EventRouter::GetWeakPtr() {
976 return weak_factory_.GetWeakPtr(); 979 return weak_factory_.GetWeakPtr();
977 } 980 }
978 981
979 } // namespace file_manager 982 } // namespace file_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698