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 "chrome/browser/chromeos/drive/drive_feed_processor.h" | 5 #include "chrome/browser/chromeos/drive/drive_feed_processor.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "chrome/browser/chromeos/drive/drive.pb.h" | 10 #include "chrome/browser/chromeos/drive/drive.pb.h" |
11 #include "chrome/browser/chromeos/drive/drive_resource_metadata.h" | 11 #include "chrome/browser/chromeos/drive/drive_resource_metadata.h" |
12 #include "chrome/browser/chromeos/drive/resource_entry_conversion.h" | 12 #include "chrome/browser/chromeos/drive/resource_entry_conversion.h" |
13 #include "chrome/browser/google_apis/gdata_wapi_parser.h" | 13 #include "chrome/browser/google_apis/gdata_wapi_parser.h" |
14 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
15 | 15 |
16 using content::BrowserThread; | 16 using content::BrowserThread; |
17 | 17 |
18 namespace drive { | 18 namespace drive { |
19 | 19 |
| 20 namespace { |
| 21 |
| 22 // Callback for DriveResourceMetadata::SetLargestChangestamp. |
| 23 // Runs |on_complete_callback|. |on_complete_callback| must not be null. |
| 24 void RunOnCompleteCallback(const base::Closure& on_complete_callback, |
| 25 DriveFileError error) { |
| 26 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 27 DCHECK(!on_complete_callback.is_null()); |
| 28 DCHECK_EQ(DRIVE_FILE_OK, error); |
| 29 |
| 30 on_complete_callback.Run(); |
| 31 } |
| 32 |
| 33 } // namespace |
| 34 |
20 class DriveFeedProcessor::FeedToEntryProtoMapUMAStats { | 35 class DriveFeedProcessor::FeedToEntryProtoMapUMAStats { |
21 public: | 36 public: |
22 FeedToEntryProtoMapUMAStats() | 37 FeedToEntryProtoMapUMAStats() |
23 : num_regular_files_(0), | 38 : num_regular_files_(0), |
24 num_hosted_documents_(0) { | 39 num_hosted_documents_(0) { |
25 } | 40 } |
26 | 41 |
27 // Increment number of files. | 42 // Increment number of files. |
28 void IncrementNumFiles(bool is_hosted_document) { | 43 void IncrementNumFiles(bool is_hosted_document) { |
29 is_hosted_document ? num_hosted_documents_++ : num_regular_files_++; | 44 is_hosted_document ? num_hosted_documents_++ : num_regular_files_++; |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 const FilePath& /* root_path */, | 390 const FilePath& /* root_path */, |
376 scoped_ptr<DriveEntryProto> /* root_proto */) { | 391 scoped_ptr<DriveEntryProto> /* root_proto */) { |
377 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 392 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
378 LOG_IF(WARNING, error != DRIVE_FILE_OK) << "Failed to refresh root directory"; | 393 LOG_IF(WARNING, error != DRIVE_FILE_OK) << "Failed to refresh root directory"; |
379 | 394 |
380 OnComplete(); | 395 OnComplete(); |
381 } | 396 } |
382 | 397 |
383 void DriveFeedProcessor::OnComplete() { | 398 void DriveFeedProcessor::OnComplete() { |
384 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 399 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
385 DCHECK(!on_complete_callback_.is_null()); | |
386 | 400 |
387 resource_metadata_->set_loaded(true); | 401 resource_metadata_->set_loaded(true); |
388 resource_metadata_->set_largest_changestamp(largest_changestamp_); | 402 resource_metadata_->SetLargestChangestamp( |
389 on_complete_callback_.Run(); | 403 largest_changestamp_, |
| 404 base::Bind(&RunOnCompleteCallback, on_complete_callback_)); |
390 } | 405 } |
391 | 406 |
392 void DriveFeedProcessor::Clear() { | 407 void DriveFeedProcessor::Clear() { |
393 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 408 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
394 | 409 |
395 entry_proto_map_.clear(); | 410 entry_proto_map_.clear(); |
396 changed_dirs_.clear(); | 411 changed_dirs_.clear(); |
397 root_upload_url_ = GURL(); | 412 root_upload_url_ = GURL(); |
398 largest_changestamp_ = 0; | 413 largest_changestamp_ = 0; |
399 on_complete_callback_.Reset(); | 414 on_complete_callback_.Reset(); |
400 } | 415 } |
401 | 416 |
402 } // namespace drive | 417 } // namespace drive |
OLD | NEW |