Home | History | Annotate | Download | only in drive_backend_v1
      1 // Copyright 2013 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #include "chrome/browser/sync_file_system/drive_backend_v1/origin_operation_queue.h"
      6 
      7 #include "base/logging.h"
      8 
      9 namespace sync_file_system {
     10 
     11 OriginOperation::OriginOperation() : type(UNKNOWN) {}
     12 OriginOperation::OriginOperation(const GURL& origin, Type type)
     13     : origin(origin), type(type) {}
     14 OriginOperation::~OriginOperation() {}
     15 
     16 OriginOperationQueue::OriginOperationQueue() {}
     17 OriginOperationQueue::~OriginOperationQueue() {}
     18 
     19 void OriginOperationQueue::Push(const GURL& origin,
     20                                 OriginOperation::Type type) {
     21   DCHECK_NE(OriginOperation::UNKNOWN, type);
     22   queue_.push_back(OriginOperation(origin, type));
     23 }
     24 
     25 OriginOperation OriginOperationQueue::Pop() {
     26   DCHECK(!queue_.empty());
     27   OriginOperation operation = queue_.front();
     28   queue_.pop_front();
     29   return operation;
     30 }
     31 
     32 bool OriginOperationQueue::HasPendingOperation(const GURL& origin) const {
     33   if (queue_.empty())
     34     return false;
     35 
     36   for (std::deque<OriginOperation>::const_iterator iter = queue_.begin();
     37        iter != queue_.end(); ++iter) {
     38     if (iter->origin == origin)
     39       return true;
     40   }
     41 
     42   return false;
     43 }
     44 
     45 }  // namespace sync_file_system
     46