DirectoryEntryPtr
MetaDataStore::rename(const ObjectId& from_parent,
                      const std::string& from,
                      const ObjectId& to_parent,
                      const std::string& to)
{
    LOG_TRACE(from << " -> " << to);

    FrontendPath from_path(find_path(from_parent));
    from_path /= from;

    FrontendPath to_path(find_path(to_parent));
    to_path /= to;

    boost::optional<DirectoryEntryPtr>
        maybe_overwritten(harakoon_.rename<DirectoryEntry>(yt::UUID(from_parent.str()),
                                                           from,
                                                           yt::UUID(to_parent.str()),
                                                           to));
    drop_from_cache(from_path);

    DirectoryEntryPtr dentry;

    if (maybe_overwritten)
    {
        drop_from_cache(to_path);
        dentry = *maybe_overwritten;
    }

    return dentry;
}
Exemple #2
0
ObjectId
WrapperOwner::idOfUnchecked(JSObject *obj)
{
    MOZ_ASSERT(IsCPOW(obj));

    Value v = GetProxyExtra(obj, 1);
    MOZ_ASSERT(v.isDouble());

    ObjectId objId = ObjectId::deserialize(BitwiseCast<uint64_t>(v.toDouble()));
    MOZ_ASSERT(!objId.isNull());

    return objId;
}
Exemple #3
0
void QtIVIWidget::contextMenu(QPoint pos)
{
    QModelIndex index = m_objectTreeView->indexAt(pos);
    if (!index.isValid())
        return;
    index = index.sibling(index.row(), 0);
    const ObjectId objectId = index.data(ObjectModel::ObjectIdRole).value<ObjectId>();
    if (objectId.isNull())
        return;

    QMenu menu;
    ContextMenuExtension ext(objectId);
    ext.populateMenu(&menu);
    menu.exec(m_objectTreeView->viewport()->mapToGlobal(pos));
}
void
MetaDataStore::add(const ObjectId& parent,
                   const std::string& name,
                   DirectoryEntryPtr dentry)
{
    LOG_TRACE(parent << ", dentry uuid " << dentry->object_id() << " name " << name);

    const yt::UUID p(parent.str());
    const boost::optional<DirectoryEntry> oldval;

    try
    {
        harakoon_.test_and_set(p,
                               name,
                               *dentry,
                               oldval);
    }
    catch (HierarchicalArakoon::PreconditionFailedException)
    {
        throw FileExistsException("Metadata entry already exists",
                                  name.c_str(),
                                  EEXIST);
    }

    FrontendPath path(find_path(parent));
    path /= name;

    maybe_add_to_cache_(path, dentry);
}
Exemple #5
0
JSObject*
WrapperOwner::fromRemoteObjectVariant(JSContext* cx, const RemoteObject& objVar)
{
    ObjectId objId = ObjectId::deserialize(objVar.serializedId());
    RootedObject obj(cx, findCPOWById(objId));
    if (!obj) {

        // All CPOWs live in the privileged junk scope.
        RootedObject junkScope(cx, xpc::PrivilegedJunkScope());
        JSAutoRealm ar(cx, junkScope);
        RootedValue v(cx, UndefinedValue());
        // We need to setLazyProto for the getPrototype/getPrototypeIfOrdinary
        // hooks.
        ProxyOptions options;
        options.setLazyProto(true);
        obj = NewProxyObject(cx,
                             &CPOWProxyHandler::singleton,
                             v,
                             nullptr,
                             options);
        if (!obj)
            return nullptr;

        if (!cpows_.add(objId, obj))
            return nullptr;

        nextCPOWNumber_ = objId.serialNumber() + 1;

        // Incref once we know the decref will be called.
        incref();

        AuxCPOWData* aux = new AuxCPOWData(objId,
                                           objVar.isCallable(),
                                           objVar.isConstructor(),
                                           objVar.isDOMObject(),
                                           objVar.objectTag());

        SetProxyReservedSlot(obj, 0, PrivateValue(this));
        SetProxyReservedSlot(obj, 1, PrivateValue(aux));
    }

    if (!JS_WrapObject(cx, &obj))
        return nullptr;
    return obj;
}
Exemple #6
0
static RemoteObject
MakeRemoteObject(JSContext* cx, ObjectId id, HandleObject obj)
{
    return RemoteObject(id.serialize(),
                        JS::IsCallable(obj),
                        JS::IsConstructor(obj),
                        dom::IsDOMObject(obj),
                        GetRemoteObjectTag(obj));
}
Exemple #7
0
void ToolManager::selectObject(ObjectId id, const QString &toolId)
{
    switch (id.type()) {
    case ObjectId::Invalid:
        return;
    case ObjectId::QObjectType:
    {
        QMutexLocker lock(Probe::objectLock());
        if (!Probe::instance()->isValidObject(id.asQObject()))
            return;

        Probe::instance()->selectObject(id.asQObject(), toolId);
        break;
    }
    case ObjectId::VoidStarType:
        Probe::instance()->selectObject(id.asVoidStar(), id.typeName());
        break;
    }
}
Exemple #8
0
bool
WrapperAnswer::RecvDropObject(const ObjectId &objId)
{
    JSObject *obj = objects_.find(objId);
    if (obj) {
        objectIdMap(objId.hasXrayWaiver()).remove(obj);
        objects_.remove(objId);
    }
    return true;
}
Exemple #9
0
BufferRefVector ResoundSession::lookup_buffer(ObjectId id){
    BufferRefVector ret;
    if(id.find('.') != std::string::npos){
        BufferRefMap::iterator it = buffers_.find(id);
        if(it != buffers_.end()){
            ret.push_back(it->second);
        }
    } else {
        for(BufferRefMap::iterator it = buffers_.begin(); it != buffers_.end(); ++it){
            ObjectId s = it->first;
            ObjectId left = s.substr(0,s.find('.'));
            if(id == left){
                ret.push_back(it->second);
            }
            
        }
    }
    return ret;
}
events::Event
FileSystemEvents::owner_changed(const ObjectId& oid,
                                const NodeId& new_owner_id)
{
    events::Event ev;
    auto msg = ev.MutableExtension(events::owner_changed);

    msg->set_name(oid.str());
    msg->set_new_owner_id(new_owner_id.str());

    return ev;
}
void
MetaDataStore::unlink(const ObjectId& id,
                      const std::string& name)
{
    LOG_TRACE(id);

    FrontendPath path(find_path(id));
    path /= name;

    harakoon_.erase(yt::UUID(id.str()), name);
    drop_from_cache(path);
}
Exemple #12
0
bool
WrapperOwner::toObjectVariant(JSContext* cx, JSObject* objArg, ObjectVariant* objVarp)
{
    RootedObject obj(cx, objArg);
    MOZ_ASSERT(obj);

    // We always save objects unwrapped in the CPOW table. If we stored
    // wrappers, then the wrapper might be GCed while the target remained alive.
    // Whenever operating on an object that comes from the table, we wrap it
    // in findObjectById.
    unsigned wrapperFlags = 0;
    obj = js::UncheckedUnwrap(obj, true, &wrapperFlags);
    if (obj && IsCPOW(obj) && OwnerOf(obj) == this) {
        *objVarp = LocalObject(idOf(obj).serialize());
        return true;
    }
    bool waiveXray = wrapperFlags & xpc::WrapperFactory::WAIVE_XRAY_WRAPPER_FLAG;

    ObjectId id = objectIdMap(waiveXray).find(obj);
    if (!id.isNull()) {
        MOZ_ASSERT(id.hasXrayWaiver() == waiveXray);
        *objVarp = MakeRemoteObject(cx, id, obj);
        return true;
    }

    // Need to call PreserveWrapper on |obj| in case it's a reflector.
    // FIXME: What if it's an XPCWrappedNative?
    if (mozilla::dom::IsDOMObject(obj))
        mozilla::dom::TryPreserveWrapper(obj);

    id = ObjectId(nextSerialNumber_++, waiveXray);
    if (!objects_.add(id, obj))
        return false;
    if (!objectIdMap(waiveXray).add(cx, obj, id))
        return false;

    *objVarp = MakeRemoteObject(cx, id, obj);
    return true;
}
Exemple #13
0
void ToolManager::requestToolsForObject(ObjectId id)
{
    ToolInfos toolInfos;
    switch (id.type()) {
    case ObjectId::Invalid:
        return;
    case ObjectId::QObjectType:
    {
        QMutexLocker lock(Probe::objectLock());
        if (!Probe::instance()->isValidObject(id.asQObject()))
            return;

        toolInfos = toolsForObject(id.asQObject());
        break;
    }
    case ObjectId::VoidStarType:
        const auto asVoidStar = reinterpret_cast<void *>(id.id());
        toolInfos = toolsForObject(asVoidStar, id.typeName());
        break;
    }
    emit toolsForObjectResponse(id, toolInfos);
}
static RemoteObject
MakeRemoteObject(JSContext* cx, ObjectId id, HandleObject obj)
{
    nsCString objectTag;

    nsCOMPtr<nsIRemoteTagService> service =
        do_GetService("@mozilla.org/addons/remote-tag-service;1");
    if (service) {
        RootedValue objVal(cx, ObjectValue(*obj));
        service->GetRemoteObjectTag(objVal, objectTag);
    }

    return RemoteObject(id.serialize(),
                        JS::IsCallable(obj),
                        JS::IsConstructor(obj),
                        dom::IsDOMObject(obj),
                        objectTag);
}
Exemple #15
0
 ObjectId ObjectId::makeObjectId()
 {
    ObjectId oid;
    oid.gen();
    return oid;
 }
uint32 SystemManager::GetKeyForMap(const ObjectId& id) const
{
	return id.GetId();
}
Exemple #17
0
 std::size_t hash_value(const ObjectId& oid) {
     const CORBA::Octet* start = oid.get_buffer();
     return boost::hash_range(start, start+oid.length());
 }
FrontendPath
MetaDataStore::find_path(const ObjectId& id)
{
    return FrontendPath(harakoon_.get_path_by_id(yt::UUID(id.str())).str());
}